帮忙看下哪错了,应怎样改?谢谢无限感谢!~

[复制链接]
查看11 | 回复1 | 2009-4-25 15:15:04 | 显示全部楼层 |阅读模式
帮忙看下哪错了,应怎样改?谢谢!~~
class Date
{
private:
int year,month,day;
public:
Date(int a,int b,int c)
{year=a;month=b;day=c;}
Date(Date &n)
{year=n.year;
month=n.month;
day=n.day;
}
int Getyear(){return year;}
int Getmonth(){return month;}
int Getday(){return day;}
};
class employee
{
protected:
int individualEmpNo;
char sex;
Date birthday;
char cardNo[20];
static int employeeNo;
public:
employee(Date xbirthday);
~employee();
void SetcardNo(char *);
char * GetcardNo();
int GetindividualEmpNo();
void Setsex(char p);
char Getsex();
};
#include
int employee::employeeNo=1000;
employee::employee(Date xbirthday)
:birthday(xbirthday)
{individualEmpNo=employeeNo++;sex='\0';}
employee::~employee(){}
void employee::SetcardNo(char *Number)
{strcpy(cardNo,Number);}
void employee::Setsex(char p)
{sex=p;}
char employee::Getsex()
{return sex;}
#include
using namespace std;
int main()
{
employee emp[20];
Date date[20];
char cnumber[20];
char p;
int i,x,y,z;
for(i=0;i>p;
emp.Setsex(p);
cout>x>>y>>z;
date(x,y,z);
cout>cnumber;
emp.SetcardNo(cnumber);
}
//显示信息
for(i=0;i<4;i++)
{
cout<<"编号:"<<emp.GetindividualEmpNo()<<"性别:"<<emp.Getsex()<<"出生日期:"
<<date.Getyear()<<"-"<<date.Getmonth()<<"-"<<date.Getday()<<"身份证号:"
<<emp.GetcardNo()<<endl;
}
return 0;
}
编绎器提示有如此错误:
employee emp[20]错误:'employee' : no appropriate default constructor available
Date date[20];错误: error C2512: 'Date' : no appropriate default constructor available
date(x,y,z);错误: term does not evaluate to a function

回复

使用道具 举报

千问 | 2009-4-25 15:15:04 | 显示全部楼层
过了class Date { private:int year,month,day; public:Date(){year = month = day = 0;} Date(int a,int b,int c){year=a;month=b;day=c;} Date(Date &n){year=n.year;month=n.month;day=n.day;} void SetDate(int a,int b,int c){year=a;month=b;day=c;} int Getyear(){return year;}int G...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行