I have two classes which contain references to each other. Node refers to info and info contains pointer to Node itself. Both have been declared friend of each other. I get errors saying the types cannot be recognized.
Basically I am trying to make a graph with nodes where each node contains and a vector of addresses and distances of neighboring nodes.
What's the right format for such a declaration using both classes and structures?
1 2 3 4 5 6 7 8 9 10 11 12 13
class Node {
public:
Node(){}
vector <info> nebors; int a; float b;
friendclass info;
};
class info {
public:
info (){}
Node * a; int distance;
friendclass Node;
};
class info; // Incomplete class definition
class Node {
public:
Node(){}
vector <info> nebors; int a; float b;
friendclass info;
};
class info {
public:
info (){}
Node * a; int distance;
friendclass Node;
};