home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / compiler / rtti / impl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-20  |  1.3 KB  |  51 lines

  1. //
  2. // class definitions 
  3. // provided by the library vendor 
  4. //
  5.  
  6. class employee {
  7.   char* Name; 
  8. protected:
  9.   int hourRate;
  10. public:
  11.   employee(char* n, int hr); 
  12.   ~employee();
  13.  
  14.   char* name() { return Name; }
  15.   virtual int salary()=0;
  16. };
  17.  
  18. class manager : public employee {
  19.   int Experience;
  20. public:
  21.   manager(char* n, int hr, int ex) : employee(n, hr), Experience(ex) { }
  22.   int salary();
  23. };
  24.  
  25. // 
  26. // The user modified the class 'programmer' provided 
  27. // by the library vendor to add the data members Overtime 
  28. // and OvertimeRate, and the member functions setOvertimeRate, 
  29. // addOvertime, resetOvertime and overtimePay.
  30. //
  31. // Because the library vendor didn't provide the source
  32. // code for impl.C, users cannot recompile impl.C and 
  33. // therefore cannot add any virtual member functions
  34. // (i.e. modify the virtual function table) of the base class 
  35. // 'employee'.
  36. //
  37.  
  38. class programmer : public employee {
  39.   int OvertimeRate;
  40.   int Overtime;
  41. public:
  42.   programmer(char* n, int hr) : employee(n, hr) { }
  43.   void setOvertimeRate(int or) { Overtime = 0; OvertimeRate = or; }
  44.  
  45.   void addOvertime(int ov) { Overtime += ov; }
  46.   void resetOvertime() { Overtime = 0; }
  47.   int overtimePay() { return Overtime*OvertimeRate; }
  48.  
  49.   int salary() ;
  50. };
  51.