home *** CD-ROM | disk | FTP | other *** search
- #include <iostream.h>
-
- class Base {
- public:
- // Do nothing
- void BaseFunc() { cout << "In Base.\n"; }
-
- // Now polymorphic so we can use RTTI
- virtual void Nothing() { }
- };
-
- class Middle1 : virtual public Base {
- public:
- // Do nothing (not a polymorphic class)
- void Middle1Func() { cout << "In Middle1.\n"; }
- };
-
- class Middle2 : virtual public Base {
- public:
- // Do nothing (not a polymorphic class)
- void Middle2Func() { cout << "In Middle2.\n"; }
- };
-
- class Derived : public Middle1, public Middle2 {
- public:
- // Do nothing (not a polymorphic class)
- void DerivedFunc() { cout << "In Derived.\n"; }
- };
-
- void main()
- {
- Derived MyDerived;
- Middle1* pMiddle1 = dynamic_cast<Middle1*>(&MyDerived);
- pMiddle1->Middle1Func();
- Middle2* pMiddle2 = dynamic_cast<Middle2*>(pMiddle1);
- pMiddle2->Middle2Func();
- }
-