求做一道C++题目,请大家帮忙
设计一个雇员类Employee,存储雇员的编号,姓名和生日等信息,要求该类使用日期类作为成员对象,雇员类的使用如下://定义一个雇员,其雇员号为10,生日为1980年11月20日
Employee Tom("Tom", 10, 1980, 11, 20);
Date today(1980, 11, 20);
if(Tom.IsBirthday(today)) //判断今天是不是Tom的生日
程序代码:#include<string>
#include<iostream>
using namespace std;
class Date;
class Employee;
class Date
{
private:
int year,month,day;
public:
Date();
Date(int,int,int);
~Date();
friend class Employee;
};
///////////////////////////////////
Date::Date()
{
cout<<"the year:";
cin>>year;
cout<<"the month:";
cin>>month;
cout<<"the day:";
cin>>day;
}
Date::Date(int year_,int month_,int day_):year(year_),month(month_),day(day_)
{
}
Date::~Date(){};
///////////////////////////////////
class Employee
{
private:
int no,birth_y,birth_m,birth_d;
string name;
public:
Employee(string,int,int,int,int);
~Employee();
bool IsBirthday(Date);
};
///////////////////////////////////////
Employee::Employee(string name_,int no_,int birth_y_,int birth_m_,int birth_d_):\
name(name_),birth_y(birth_y_),birth_m(birth_m_),birth_d(birth_d_)
{
}
Employee::~Employee(){};
bool Employee::IsBirthday(Date today)
{
if(today.month==birth_m&&today.day==birth_d)return true;
else return false;
}
///////////////////////////////////////
int main()
{
Employee Tom("Tom",1,1991,5,20);
Date today(2015,5,22);
if(Tom.IsBirthday(today))cout<<"happy birthday!\n";
else cout<<"not the day today\n";
return 0;
}