Aus irgendeinem Grund erkennt meine main.cpp nicht den Typ Link, der durch eine link.h-Datei enthalten und in link.cpp definiert ist. Ist es möglich, dass das Makefile sie nicht richtig verbindet, andernfalls sollte afaik ich link.h sowohl in link.cpp als auch in main.cpp enthalten und beide könnten Link als Klasse erkennen.C++ unbekannter Typ Fehler
main.cpp
#include <iostream>
#include <link.h>
int main (int argc, const char * argv[]) {
int i = 10;
while(i >= 0) {
i--;
}
Link test = new Link();
std::cout << "Hello, World!2\n";
return 42;
}
link.h
#ifndef LINK_H
#define LINK_H
#include <string>
using namespace std;
class Link {
private:
string * value;
Link * next;
public:
Link(Link * nextLink, string * stringValue);
~Link();
}
#endif
link.cpp
#include <link.h>
Link::Link(Link * nextLink, string * stringValue) {
this.next = nextLink;
this.value = stringValue;
}
Link::~Link() {
delete value;
}
Link * Link::getNext() {
return next;
}
string * Link::getString() {
return value;
}
void Link::printAll() {
if (next != NULL) {
cout << value << "\n" << next->printAll();
} else {
cout << value << "\n";
}
}
, wie Sie sie in Ihrem Make-Datei verknüpfen? –
Ihre Link-Klasse scheint ein schließendes Semikolon zu fehlen. –