convoluted definitions

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;
friend class info;
};

class info {
public:
info (){}
Node * a; int distance;
friend class Node;
}; 
Last edited on
Incomplete class definition

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class info; // Incomplete class definition

class Node {
public:
Node(){}
vector <info> nebors; int a; float b;
friend class info;
};

class info {
public:
info (){}
Node * a; int distance;
friend class Node;
}; 
Topic archived. No new replies allowed.