home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / m / mar93.zip / 1103108A < prev    next >
Text File  |  1993-01-08  |  527b  |  49 lines

  1. #include <iostream.h>
  2.  
  3. class B
  4.     {
  5. public:
  6.     void f();
  7.     void g();
  8.     void h();
  9.     };
  10.  
  11. void B::f() { cout << "B::f()\n"; }
  12.  
  13. void B::g() { cout << "B::g()\n"; }
  14.  
  15. void B::h() { cout << "B::h()\n"; }
  16.  
  17. class D : public B
  18.     {
  19. public:
  20.     void g();
  21.     void h();
  22.     };
  23.  
  24. void D::g()
  25.     {
  26.     B::g();
  27.     cout << "... called from D::g()\n";
  28.     }
  29.  
  30. void D::h()
  31.     {
  32.     ((B *)(this))->h();
  33.     cout << "... called from D::h()\n";
  34.     }
  35.  
  36. int main()
  37.     {
  38.     B b;
  39.     b.f();
  40.     b.g();
  41.     b.h();
  42.     D d;
  43.     d.f();
  44.     d.g();
  45.     d.h();
  46.     return 0;
  47.     }
  48.  
  49.