class CBirthday
{
public:
CBirthday(int year = 0,int month = 0,int day = 0)
:m_iYear(year),m_iMonth(month),m_iDay(day)
{
}
~CBirthday(){}
CBirthday(const CBirthday& birthday)
{
m_iYear = birthday.m_iYear;
m_iMonth = birthday.m_iMonth;
m_iDay = birthday.m_iDay;
}
void Show()
{
cout << m_iYear <<" "<< m_iMonth <<" "<< m_iDay <<endl;
}
private:
int m_iYear;
int m_iMonth;
int m_iDay;
};
class CStudent
{
public:
CStudent(char name[20],int id,CBirthday birthday)
{
strcpy(this->name,name);
this->id = id;
this->birthday = birthday;
}
~CStudent(){}
CStudent(const CStudent& student)
{
strcpy(this->name,student.name);
this->id = student.id;
this->birthday = student.birthday;
}
void Show()
{
cout << name <<" " << id <<" ";
birthday.Show();
}
private:
char name[20];
int id;
CBirthday birthday;
};
void main()
{
CBirthday b(2000,1,1);
CStudent s("Tom",1,b);
b.Show();
s.Show();
getchar();
}