#include <iostream>
#include <cstring>
using namespace std;
class Teacher
{public:
Teacher(int,char [],char);
void display();
private:
int num;
char name[20];
char sex;
};
Teacher::Teacher(int n,char nam[],char s)
{num=n;
strcpy(name,nam);
sex=s;
}
void Teacher::display()
{cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
}
class BirthDate
{public:
BirthDate(int,int,int);
void display();
void change(int,int,int);
private:
int year;
int month;
int day;
};
BirthDate::BirthDate(int y,int m,int d)
{year=y;
month=m;
day=d;
}
void BirthDate::display()
{cout<<"birthday:"<<month<<"/"<<day<<"/"<<year<<endl;}
void BirthDate::change(int y,int m,int d)
{year=y;
month=m;
day=d;
}
class Professor:public Teacher
{public:
Professor(int,char [],char,int,int,int,float);
void display();
void change(int,int,int);
private:
float area;
BirthDate birthday;
};
Professor::Professor(int n,char nam[20],char s,int y,int m,int d,float a):
Teacher(n,nam,s),birthday(y,m,d),area(a){ }
void Professor::display()
{Teacher::display();
birthday.display();
cout<<"area:"<<area<<endl;
}
void Professor::change(int y,int m,int d)
{birthday.change(y,m,d);
}
int main()
{Professor prof1(3022,"ZHANG",'m',1951,1,3,125.4);
cout<<endl<<"original data:"<<endl;
prof1.display();
cout<<endl<<"new data:"<<endl;
prof1.change(1950,1,2);
prof1.display();
return 0;
}
#include <cstring>
using namespace std;
class Teacher
{public:
Teacher(int,char [],char);
void display();
private:
int num;
char name[20];
char sex;
};
Teacher::Teacher(int n,char nam[],char s)
{num=n;
strcpy(name,nam);
sex=s;
}
void Teacher::display()
{cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
}
class BirthDate
{public:
BirthDate(int,int,int);
void display();
void change(int,int,int);
private:
int year;
int month;
int day;
};
BirthDate::BirthDate(int y,int m,int d)
{year=y;
month=m;
day=d;
}
void BirthDate::display()
{cout<<"birthday:"<<month<<"/"<<day<<"/"<<year<<endl;}
void BirthDate::change(int y,int m,int d)
{year=y;
month=m;
day=d;
}
class Professor:public Teacher
{public:
Professor(int,char [],char,int,int,int,float);
void display();
void change(int,int,int);
private:
float area;
BirthDate birthday;
};
Professor::Professor(int n,char nam[20],char s,int y,int m,int d,float a):
Teacher(n,nam,s),birthday(y,m,d),area(a){ }
void Professor::display()
{Teacher::display();
birthday.display();
cout<<"area:"<<area<<endl;
}
void Professor::change(int y,int m,int d)
{birthday.change(y,m,d);
}
int main()
{Professor prof1(3022,"ZHANG",'m',1951,1,3,125.4);
cout<<endl<<"original data:"<<endl;
prof1.display();
cout<<endl<<"new data:"<<endl;
prof1.change(1950,1,2);
prof1.display();
return 0;
}