#include <iostream>
using namespace std;
/*假设基类中函数被重载,当派生类覆盖基类的成员函数时,会隐藏到基类的其他的重载函数
* 注:应该尽量避免隐藏基类的成员函数
*/
class Person {
protected: //只能在派生类内部访问protected成员,外部不可访问
bool man;
public: // public权限,可被派生类访问
void CheckPerson();
void CheckPerson(int age);
Person(bool initValue) { //构造函数的重载,带初始值
man = initValue;
cout << "Person constructor" << endl;
}
~Person() {
cout << "~Person deconstructor" << endl;
}
};
void Person::CheckPerson() {
if (man)
cout << "Person is man" << endl;
else
cout << "Person is woman" << endl;
}
void Person::CheckPerson(int age) {
if (man)
cout << "man age is " << ag