I\'m having some problems with forward declaration, well, I\'m confused about everything. I have 3 classes that depend on each other. For example:
#include
using namespace std;
class B;
class C;
class A{
public:
static B instanceOfB;
static C instanceOfC;
static void foo(){
cout << "A static foo called"<< endl;
}
};
class C{
static A instanceOfA;
};
A C::instanceOfA = A();
class B{
A instanceOfA;
};
B A::instanceOfB = B();
int main(){
cout << "main run"<
1st, it is a bad design when class depends on each other. 2nd, this kind of depends should doesn't mean you have to hold the object of the class, instead, if this dependent is complicated, you need to use a "pointer" to the object instead of holding the object. "Pointer to object" means compiler will not require the full prototype of that class.