Possible Duplicates:
C++ pointer multi-inheritance fun.
more c++ multiple inheritance fun
This is a problem that arose from dealing with ref-counted pointer base class and threading fun.
Given:
class A{int x, y;};
class B{int xx, yy;};
class C: public A, public B {int z;};
C c;
C* pc = &c;
B* pb = CtoB(pc);
A* pa = CtoA(pc);
assert(pc == AtoC(pa));
assert(pc == BtoC(pb));
How do I write CtoB and CtoA to get the B & A parts of C?
How to I write AtoC and BtoC to get back the original C?
Thanks!
Why the votes to close?
My previous two questions asked if something was valid (the answer was "no"); this question asks "what is the valid way to do pointer conversion."