I was planning to produce a data structure for representing graphs. I have written to below snippet. As you can see Edge name is used in Vertex declaration and Vertex name is used in Edge declaration. The compiler gives error when it sees Edge* line in first class declaration. When I switch their places it also give error since it sees Vertex* line in Edge declaration. I am using GNU gcc compiler. How can I solve this problem ? For same reason so far I was placing my main() function at the undermost part of the code in my works. Is it how should it be, always?
class Vertex
{
public:
long int A =1000000;
Edge* edges[no] ={NULL};
bool visited =0;
};
class Edge
{
public:
Vertex* X;
int cost;
};