C++ (Qt)class A{public: int e; virtual void func();};void A::func(){ e=3;} class B: public A{public: double h;}; class C: public B{public: int c;};
C++ (Qt)#include <QtGui> struct A { int testA; virtual int Test( void ) { return 0; }}; struct B : public A { int testB; virtual int Test( void ) { return 1; }}; struct C : public A { int testC; virtual int Test( void ) { return 2; }}; C * TestCast2C( B * testB ){ return dynamic_cast <C *> (testB);} int main(int argc, char **argv){ B * testB = (B *) new C(); C * testC = TestCast2C(testB); printf("testB = %p, testC = %p\n", testB, testC); return 0;}
C++ (Qt)B * testB = (B *) new C();
C++ (Qt)C * TestCast2C( B * testB ){ return dynamic_cast <C *> (testB);}