1 // employee.h 2 // 3 // Employee class hierarchy using inheritance 4 // The Employee is the base class for subclasses manager, scientist, 5 // and laborer, and laborer is the base class for a subclass foreman. 6 7 // Taken from LaFore, Robert. 1996. "C++ Interactive Course", 8 // Corte Madera, CA: The Waite Group, Inc. p. 398-402. 9 // 10 #include <iostream.h> 11 12 const int LEN = 80; // maximum length of names 13 14 class Employee 15 { 16 public: 17 void getData(); 18 void putData(); 19 private: 20 char name[LEN]; // employee name 21 unsigned long number; // employee number 22 }; 23 24 class Manager : public Employee 25 { 26 public: 27 void getData (); 28 void putData(); 29 private: 30 char title[LEN]; // employee title, i.e. "vice-president" 31 double dues; // golf club dues 32 }; 33 34 class Scientist: public Employee 35 { 36 public: 37 void getData (); 38 void putData(); 39 private: 40 int numberPubs; // number of publications 41 }; 42 43 class Laborer: public Employee 44 { 45 public: 46 void getData (); 47 void putData(); 48 private: 49 int numberHours; // hours worked this week 50 }; 51 52 class Foreman: public Laborer 53 { 54 public: 55 void getData (); 56 void putData(); 57 private: 58 float quotas; // percentage of quotas met successfully 59 }; |