home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_09 / 2n09065a < prev    next >
Text File  |  1991-07-26  |  654b  |  34 lines

  1. // VIRTUAL.L - Demonstrate all member functions are virtual.
  2.  
  3. class base
  4. {
  5.     print() { w << "Base class\n"; }
  6.     print2() { print(); }
  7.     baseprint() { base::print(); }
  8. };
  9.  
  10. class derived : base
  11. {
  12.     print() { w << "Derived class\n"; }
  13. };
  14.  
  15. main() {
  16.     w   = new textwindow ("base vs. derived");
  17.     w.show();
  18.     base b = new base;
  19.     derived d = new derived;
  20.     w << "b.print():";
  21.     b.print();
  22.     w << "b.print2():";
  23.     b.print2();
  24.     w << "b.baseprint():";
  25.     b.baseprint();
  26.     w << "d.print():";
  27.     d.print();
  28.     w << "d.print2():";
  29.     d.print2();
  30.     w << "d.baseprint():";
  31.     d.baseprint();
  32.     }
  33.  
  34.