#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
class Data{//日期类
public:
Data(){}
Data(int y,int m,int d){
m_year=y;
m_month=m;
m_day=d;
}
int get_year(){
return m_year;
}
int get_month(){
return m_month;
}
int get_day(){
return m_day;
}
void set_year(int y){
m_year=y;
}
void set_month(int m){
m_month=m;
}
void set_day(int d){
m_day=d;
}
private:
int m_year;
int m_month;
int m_day;
};
class Person{//人员类
public:
Person(){}
Person(int n,int sex, Data birth, string id){//构造函数
m_number=n;
m_sex=sex;
m_birthday=birth;
m_id=id;
}
Person(Person *temp){//拷贝构造函数
m_number=temp->get_number();
m_sex=temp->get_sex();
m_birthday=temp->get_birthday();
m_id=temp->get_id();
}
~Person(){
}
inline int get_number(){//内联成员函数
return m_number;
}
int get_sex(){
return m_sex;
}
Data get_birthday(){
return m_birthday;
}
string get_id(){
return m_id;
}
Person addperson(){//人员信息的录入
int number,sex,year,month,day;
string id;
cout<<"Please input the number of the employee:";
cin>>number;
cout<<"Please input the sex of the employee (1 for male, 0 for female):";
cin>>sex;
cout<<"Please input the birthday of the employee,\n"
<<"for example,\"1984 7 21\"\n";
cin>>year>>month>>day;
cout<<"Please input the id of the employee:";
cin>>id;
Data birthday(year,month,day);
m_number=number;
m_sex=sex;
m_birthday=birthday;
m_id=id;
return this;
}
void show(){//人员信息的显示
string sex=m_sex>0?"male":"female";
cout<
private:
int m_number;
int m_sex;
Data m_birthday;//日期类 内嵌子对象
string m_id;
};
int _tmain(int argc, _TCHAR* argv[])
{
Person p;
p.addperson();
p.show();
return 0;
}