I have two classes, and both of them use some other classes, for example:
class Class1;
#include "class2.h"
class Class1 {
public:
static Class2 *C2;
...
};
class Class2;
#include "class1.h"
class Class2 {
public:
static Class1 *C1;
...
};
And when I define it, as in the example above, it works (I also have #ifndefit to avoid endless repeatability of the header). But I also want to add some built-in functions to my classes. And I read here that I have to put the definition of the inline function in the header file, because it will not work if I put them in a cpp file and want to call them from another cpp file (when I do this, I get an undefined link during the link ) But the problem here is this:
...
inline void Class1::Foo() {
C2->Bar();
}
I get the error: Invalid use of incomplete type 'struct Class2.
So how can I do this?