C++问题,求助..

来源:百度知道 编辑:UC知道 时间:2024/06/23 00:19:24
十万火急..我实在不懂哪错了...哎..我分就这么多了..我全拿出来了..希望各位伸出援手,万分感谢!!
题目是:
设计一个雇员类employee,该类对象可存储雇员的姓名、编号、生日等信息,要求使再设计一个日期类作为对象成员表示生日。雇员类的使用如:
employee a(“Smith”, “10”, 1978, 11, 25);
// 对象a表示雇员Smith,编号为10,1978年11月25日出生
date Today;

if (a.isBirth(Today)) ……. // 判断今天是否为某雇员的生日

下面是我写的代码:
#include <iostream.h>
#include <string.h>
class Date
{ int year,month,day;
public:
void setdate(int y,int m,int d){year=y;month=m;day=d;}
void print(){cout<<year<<","<<month<<","<<day<<endl;}
int getyear(){return year;}
int getmonth(){return month;}
int getday(){return day;}
};

class Employee//13
{
string name;int num,year,month,day;//15
public:
Date birth;
Employee(string,int,int,int,int);//18
bool isBirth(Date);
string getname(){return name;};//20
Date getda

bool Employee::isBirth(Date d)
{
if(birth.getyear()==d.getyear() && birth.getday==d.getday && birth.getmonth = d.getmonth() )
return true;
else
return false;
}

改成这样就可以了
#include <iostream>
#include <string>
using namespace std; //用C++就要写名字空间,否则有些东西不认。

class Date
{ int year,month,day;
public:
void setdate(int y,int m,int d){year=y;month=m;day=d;}
void print(){cout<<year<<","<<month<<","<<day<<endl;}
int getyear(){return year;}
int getmonth(){return month;}
int getday(){return day;}
};

class Employee//13
{
string name;
int num,year,month,day;//15
public:
Date birth;
Employee(string,int,int,int,int);//18
bool isBirth(Date);
string getname(){return name;};//20
Date getdate(){return birth;}; //birth拼写错误
};
Employee::Employee(st