There was a bug that stumped me for a while and I'd like to know the exact reason why this is happening.
I'm going to simplify the problem here.
When I create a new instance of Derived and call DoSomething2(), the function that gets invoked is DoSomething1()Code:class Base1 - Concrete class { virtual void DoSomething1(){} } class Base2 - Abstract class { virtual void DoSomething2()=0; } class Derived : Base1, Base2 { void DoSomething1(){} void DoSomething2(){} }
However, here is what the root cause appears to be.
EDIT: Example was slightly off we are casting back to Base2.
How come casting to a DWORD and then casting back to Derived* screws things up?Code:Derived *d = new Derived(); DWORD dPtr = (DWORD)d; Base2 *b2 = (Base2*) dPtr; b2->DoSomething2(); //DoSomething1() is called




Reply With Quote