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;
- Base* pBase = dynamic_cast<Base*>(&MyDerived);
- pBase->BaseFunc();
- Derived* pDerived = dynamic_cast<Derived*>(pBase);
- pDerived->DerivedFunc();
- }
-