I have two classes, Foo and FooBox. FooBox contains a vector that stores Foo objects, so the FooBox.h file looks something like:
and the Foo.h file looks like
This code won't compile in Visual C++ 6.0, and I'm guessing it has something to do with these circular includes. If I put the #include lines outside the #ifndef blocks, I get an error message from the compiler about possible infinite recursion; otherwise, I get an error message about the Foo class being undefined in the FooBox.h file.
How is it possible to get this kind of code to compile?
Code:
#ifndef FOOBOX
#define FOOBOX
#include "Foo.h"
class FooBox {
vector<Foo> foos;
...
};
#endif
and the Foo.h file looks like
Code:
#ifndef FOO
#define FOO
#include "FooBox.h"
class FooBox {
FooBox* parent;
...
};
#endif
This code won't compile in Visual C++ 6.0, and I'm guessing it has something to do with these circular includes. If I put the #include lines outside the #ifndef blocks, I get an error message from the compiler about possible infinite recursion; otherwise, I get an error message about the Foo class being undefined in the FooBox.h file.
How is it possible to get this kind of code to compile?