sdfs

#include <iostream>
#include <string>
using namespace std;
class BirthDate {
public:
    BirthDate(int,int,int);
    void display();
    void setbirthday(int,int,int);
private:
    int year;
    int month;
    int day;
};
BirthDate::BirthDate(int a,int b,int c):year(a),month(b),day(c){}
void BirthDate::setbirthday(int a,int b,int c)
{
    year=a;
    month=b;
    day=c;
}
void BirthDate::display()
{
    cout<<"birthday:"<<year<<"/"<<month<<"/"<<day<<endl;
}
class Teacher
{
public:
    Teacher(int,string,char);
    void display();
private:
    int num;
    string name;
    char sex;
};
Teacher::Teacher(int a,string b,char c):num(a),name(b),sex(c){}
void Teacher::display()
{
    cout<<"num:"<<num<<endl;
    cout<<"name:"<<name<<endl;
    cout<<"sex:"<<sex<<endl;
}
class Professor:public Teacher
{
public:
    Professor(int a,string b,char c,BirthDate d);
    void display();
    void setbirthday(int,int,int);
private:
    BirthDate birthday;
};
Professor::Professor(int a,string b,char c,BirthDate d):Teacher(a,b,c),birthday(d){}
void Professor::display()
{
    Teacher::display();
    birthday.display();
}
void Professor::setbirthday(int a,int b,int c)
{
    birthday.setbirthday(a,b,c);
}
int main()
{
    int num;
    string name;
    char sex;
    int year,month,day;
    cin>>num>>name>>sex;
    cin>>year>>month>>day;
    Professor prof(num,name,sex,BirthDate(year,month,day));
    cin>>year>>month>>day;
    prof.setbirthday(year,month,day);
    prof.display();
    return 0;
}

 

 

你可能感兴趣的:(sdfs)