I have a class Node, and a struct Edge.
But when the struct is written before the class, the struct complains for no knowing what is distance.
It is the same for the the way around, when the struct is define after, the classe complain for not knowing what is a Edge (the type of the vector).
//This is my header file
typedef struct Edge Edge;
struct Edge{
Node node;
int distance;
};
class Node
{
private:
std::vector<Edge> vectorOfEdges;
};
How do I get around this error?
Thank you.
Your definition is circular: it tries to put a
Nodeinside anEdge, and a vector of edges inside aNode. You need to make one of these a pointer, for example, like this:P.S. You were missing a semicolon after the struct.