Cross-including head file? Can I? How?
I have two head files, and in each of both, I need to use the class defined in another file. For example:
In File1:
1 2 3 4 5 6
|
class a {
public:
vector<b*> v;
//......
};
|
In File2:
1 2 3 4 5 6
|
class b {
public:
vector<a*> v;
//......
};
|
I tried to include file2 in file1 and include file1 in file2. But this will cause error.
How can I reach my goal? Thanks.
If this cannot be done, then I only got one way, that is to combine these two files??? Common, there got be a way......
Last edited on
Hi there! You can use a forward declaration of the two classes in their respective files.
1 2 3 4 5 6
|
class b;//forward declaration
class a{
public:
vector<b*> v;
};
|
Topic archived. No new replies allowed.