home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 1.ddi / OOPWLD.ZIP / DIRECT / DIRECT2.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-11  |  675 b   |  19 lines

  1. // DIRECT2.HPP: Simple inheritance
  2. #include "direct.hpp"  // the original class
  3.  
  4. class dirfile2 : public dirfile {  // <-- inheritance!
  5.   static int printcount;  // one variable for all objects
  6.   // statics are automatically initialized to zero; you can
  7.   // also explicitly initialize them.
  8. public:
  9.   void print2() { // re-define the function
  10.     // start a new line every 4th call:
  11.     if(printcount++ % 4 == 0) putchar('\n');
  12.     // use scope-resolution operator to call the base-class
  13.     // function (defaults to derived-class function):
  14.     dirfile::print2();
  15.   }
  16.   // a static member function:
  17.   static void reset_printcount() { printcount = 0; }
  18. };
  19.