I have a complicated problem that boils down to this:
2 classes that work together, need to have pointers to one another and complete access to all members and function.
the challenge lies in the fact that they cannot both be created at the same time. For example, a function in one class, uses the pointer to the other class to access a function or variable that doesn't technically exist yet. In case you're confused, here's a quick example of what i'm talking about:
When compiled the compiler throws "use of undefined type B" at:Code:class B; //a prototype so that class A knows class B exists; class A { public: B *classB; //pointer to class B void fxnA(); void write(); }; void A::fxnA() { *classB->write(); } void A::write() { cout<<"A"<<endl; } class B { public: A *classA; //pointer to class A void fxnB(); void write(); }; void B::fxnB() { *classA->write(); } void B::write() { cout<<"B"<<endl; }
*classB->write(); ( in fxnA() )
If the order of the classes is switched, fxnB() will throw the same error about A.
hopefully I'm just ignorant and forgetting something.
Help??