person.h
来自「一本语言类编程书籍」· C头文件 代码 · 共 41 行
H
41 行
// 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 + =
减小字号Ctrl + -
显示快捷键?