Such that InstanceOfAalways automatically creates an instance of B and both have access to their integer members (at least public ones). Is this possible?
I am effectively asking that A and B are the same class, but with declarations in different locations (such that functions requiring members of A need not explicitely include headers for B, and vice versa)
I'm not sure. A base class doesn't "know" anything about its inherited class... Take this example:
1 2 3 4 5 6 7
struct B : public A { // ERROR
int Bint;
};
struct A : public B{
int Aint;
};
I was thinking of maybe doing this:
1 2 3 4 5 6 7 8 9 10 11 12 13
struct B {
B(A*);
A* PointerToA;
int Bint;
};
B::B(A* pA) {
PointerToA = pA;
}
struct A : public B(this){ // can I do this??
int Aint;
};
That way struct B will always have access to struct A by inheritance, and struct B can access struct A through the pointer. But can I pass a this pointer like that??