home *** CD-ROM | disk | FTP | other *** search
/ Using Visual C++ 4 (Special Edition) / Using_Visual_C_4_Special_Edition_QUE_1996.iso / ch18 / vrtbase1.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-13  |  741 b   |  35 lines

  1. #include <iostream.h>
  2.  
  3. class Base {
  4. public:
  5.     // Do nothing (not a polymorphic class)
  6.     void BaseFunc() { cout << "In Base.\n"; }
  7. };
  8.  
  9. class Middle1 : public Base {
  10. public:
  11.     // Do nothing (not a polymorphic class)
  12.     void Middle1Func() { cout << "In Middle1.\n"; }
  13. };
  14.  
  15. class Middle2 : public Base {
  16. public:
  17.     // Do nothing (not a polymorphic class)
  18.     void Middle2Func() { cout << "In Middle2.\n"; }
  19. };
  20.  
  21. class Derived : public Middle1, public Middle2 {
  22. public:
  23.     // Do nothing (not a polymorphic class)
  24.     void DerivedFunc() { cout << "In Derived.\n"; }
  25. };
  26.  
  27. void main()
  28. {
  29.     Derived  MyDerived;
  30.     Base*    pBase = (Base*) &MyDerived;
  31.     pBase->BaseFunc();
  32.     Derived* pDerived = (Derived*) pBase;
  33.     pDerived->DerivedFunc();
  34. }
  35.