I did something like this:
struct Vertex {
list<Edge*> edges;
};
struct Edge {
Vertex* v1;
Vertex* v2;
};
and the compiler error :
‘Edge’ was not declared in this scope
How do I solve this problem without putting these two into separate headers, “vertex.h” and “edge.h”?
Use forward declaration before you use
Edge.Note that when you forward declare a type the compiler treats the type as an Incomplete type, it does not know anything about the layout of the type but it just knows that the type exists, So there are some limitations of how you can use an Incomplete type.
Good Read:
When can I use a forward declaration?