В моем классе Edge есть ссылка на вершину с именем target. в Vertex я отправляю Edge и пытаюсь изменить цель через Edge, но у меня возникает ошибка компилятора: у класса Edge нет члена с именем target.
my Edge.h это
#include "Vertex.h"
class Edge
{
public:
Edge *data;
Edge *next;
Vertex *target;
Edge();
Edge(Edge
Edge(Vertex
void print();
};
ошибка вызвана этим кодом в Vertex.cpp
Vertex::Vertex(Edge
{
name = x->target->name;
next = x->target->next;
mark = x->target->mark;
previous = NULL;
next = NULL;
}
Точная ошибка при попытке скомпилировать Vertex:
g++ -g -I. -c -o Vertex.o Vertex.cpp
In file included from Vertex.h:3,
from Vertex.cpp:3:
Edge.h:10: error: ISO C++ forbids declaration of ‘Vertex’ with no type
Edge.h:10: error: expected ‘;’ before ‘*’ token
Edge.h:14: error: expected ‘)’ before ‘*’ token
Vertex.cpp: In constructor ‘Vertex::Vertex(Edge*)’:
Vertex.cpp:26: error: ‘class Edge’ has no member named ‘target’
Vertex.cpp:27: error: ‘class Edge’ has no member named ‘target’
Vertex.cpp:28: error: ‘class Edge’ has no member named ‘target’
Подробнее здесь: https://stackoverflow.com/questions/436 ... mber-named
Мобильная версия