class A {
public:
void foo() {[...]}
};
class C;
class B {
public:
C *deltaC;
B(C *gammaC) {
deltaC = gammaC; //(is there a better way of doing this?)
}
void bar() {
deltaC->alphaA->foo(); // <-- ** problem :( **
}
};
class C {
public:
friendclass B;
A *alphaA;
B *betaB;
baz() {
betaB = new B(this);
betaB->bar();
}
};
The forward declaration isn't sufficient for B::bar() because the pointer to the object of class C is dereferenced, but C's declaration cannot be made before B's, because C::baz() creates a B object. I can't see how I can make a sort of "interface" abstract class for C because of B::bar()'s use of A.
class A
{
//...
};
class C;
class B
{
//...
void bar();
};
class C
{
//...
};
inlinevoid B::bar()
{
deltaC->alphaA->foo();
}
Of course, you can simplify this and make it less fugly by putting A, B, and C in their own headers, and using the "right way" to include headers as described here: