problem:
class A
{
private:
Object* theGoal;
public:
Object* GetTheGoal() const { return theGoal; }
...
};
class B; // some other class
class C: public A, public B // multiple inherited
{
...
};
B* d = new C();
// there are 2 choices to get pointer to theGoal
Object* goal1 = ((A*)d)->GetTheGoal(); // cast B to A
Object* goal2 = ((C*)d)->GetTheGoal(); // cast B to C
questions:
0. what cast from above is correct?
1. if there are rules to avoid segmentation violation errors?
2. what is difference between declarations
class C: public A, public B
and
class C: public B, public A
3. if cast operation is platform/compiler dependent ?
Excuse me for ignorrance.
Thank in advance, with best regards, Valery