⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 person.h

📁 一本语言类编程书籍
💻 H
字号:
// Exercise 15.4 Person.h
// Person class and classes derived from Person

#ifndef PERSON_H
#define PERSON_H
#include <string>
using std::string;

class Person {
  public:
    Person():age(0), name(""), gender('f'){}            // Default constructor
    Person(int theAge, string theName, char theGender);
    void who() const;                                   // Display details

  protected:
    int age;                                            // Age in years
    string name;
    char gender;                                        // 'm' or 'f'
};

class Employee: public Person {
  public:
    Employee(){}                 // Default constructor - necessary to declare arrays
    Employee(int theAge, string theName, char theGender, long persNum):
        Person(theAge, theName, theGender), personnelNumber(persNum){}
    void who() const;    // Display details

  protected:
    long personnelNumber;

};

class Executive: public Employee {
  public:
    Executive(){}               // Default constructor - necessary to declare arrays
    Executive(int theAge, string theName, char theGender, long persNum):
        Employee(theAge, theName, theGender, persNum){}
    void who() const;           // Display details
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -