home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK4 / SAMPLES / CPPTUTOR / EMPLOYEE.H$ / EMPLOYEE
Encoding:
Text File  |  1991-12-11  |  1.3 KB  |  59 lines

  1. // EMPLOYEE.H
  2.  
  3. // This is the final version of an example class from Chapter 7 of the
  4. //     C++ Tutorial. This class demonstrates inheritance, overriding
  5. //     members of a base class, and virtual functions (including a
  6. //     pure virtual function).
  7.  
  8. #if !defined( _EMPLOYEE_H_ )
  9.  
  10. #define _EMPLOYEE_H_
  11.  
  12. class Employee
  13. {
  14. public:
  15.     Employee( const char *nm );
  16.     char *getName() const;
  17.     virtual float computePay() const = 0;      // Pure virtual function
  18.     virtual ~Employee() {}
  19. private:
  20.     char name[30];
  21. };
  22.  
  23. class WageEmployee : public Employee
  24. {
  25. public:
  26.     WageEmployee( const char *nm );
  27.     void setWage( float wg );
  28.     void setHours( float hrs );
  29.     float computePay() const;     // Implicitly virtual
  30. private:
  31.     float wage;
  32.     float hours;
  33. };
  34.  
  35. class SalesPerson : public WageEmployee
  36. {
  37. public:
  38.     SalesPerson( const char *nm );
  39.     void setCommission( float comm );
  40.     void setSales( float sales );
  41.     float computePay() const;     // Implicitly virtual
  42. private:
  43.     float commission;
  44.     float salesMade;
  45. };
  46.  
  47. class Manager : public Employee
  48. {
  49. public:
  50.     Manager( const char *nm );
  51.     void setSalary( float salary );
  52.     float computePay() const;     // Implicitly virtual
  53. private:
  54.     float weeklySalary;
  55. };
  56.  
  57. #endif  // _EMPLOYEE_H_
  58.  
  59.