对于组合问题不是很懂
继承和组合的关系:声明Professor(教授)类是Teacher(教师)类的派生类(继承关系),另有一个类BirthDate(生日)类,Professor类有一个生日数据(组合关系)。
在定义Professor类对象prof1时给出所有数据的初值,然后修改prof1的生日数据,最后输出prof1的全部最新数据,其余成员随意设计
class Teacher
{
public:
pirvate:
int num;
string name;
char sex;
};
class BirthDate
{
public:
private:
int year;
int month;
int day;
};
class Professor:public Teacher
{
public:
private:
BirthDate birthday;
};