大致上 这样编写 就可以了
#include <iostream>
#include <string>
using namespace std;
class Date{
protected:
string year;
string month;
string day;
public:
void setYear(string y){
year = y;}
void setMonth(string m){
month = m;}
void setDay(string d){
day = d;}
};
class Employee:public Date{
string num;
string name;
string sex;
string date;
string post;
public:
void setNum(string n){
num = n;}
void setName(string m){
name = m;}
void setSex(string s){
sex = s;}
void setPost(string p){
post = p;}
string getDate(){return (day + "/" + month + "/" + year);}
string getNum(){return num;}
string getName(){return name;}
string getSex(){return sex;}
string getPost(){return post;}
};
void Display(Employee &);
void Enter(string &);
int main(){
Employee info;
string num, name, sex, post, day, month, year;
cout<<"Number : ";
Enter(num);
info.setNum(num);
cout<<"Name
: ";
Enter(name);
info.setName(name);
cout<<"Birthday Info"<<endl
<<"Day : ";
Enter(day);
info.setDay(day);
cout<<"Month : ";
Enter(month);
info.setMonth(month);
cout<<"Year : ";
Enter(year);
info.setYear(year);
cout<<"Sex
: ";
Enter(sex);
info.setSex(sex);
cout<<"Post
: ";
Enter(post);
info.setPost(post);
system("cls");
cout<<"**** Employee Info ****"<<endl;
Display(info);
system("PAUSE");
return 0;
}
void Enter(string &message){
getline(cin,message);}
void Display(Employee &Info){
cout<<"Number
: "<<Info.getNum()<<endl
<<"Name
: "<<Info.getName()<<endl
<<"Date
: "<<Info.getDate()<<endl
<<"Sex
: "<<Info.getSex()<<endl
<<"Post
: "<<Info.getPost()<<endl;
}