home *** CD-ROM | disk | FTP | other *** search
- #include <iostream.h>
-
- class Base {
- public:
- // Do nothing (not a polymorphic class)
- void BaseFunc() { cout << "In Base.\n"; }
- };
-
- class Middle1 : public Base {
- public:
- // Do nothing (not a polymorphic class)
- void Middle1Func() { cout << "In Middle1.\n"; }
- };
-
- class Middle2 : 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 = (Base*) &MyDerived;
- pBase->BaseFunc();
- Derived* pDerived = (Derived*) pBase;
- pDerived->DerivedFunc();
- }
-