[求助]如何解决Debug assertion failad
#include <iostream.h>#include <string.h>
class data
{
private:
int day,month,year;
public:
data();
int getyear()
{
return year;
}
int getmonth()
{
return month;
}
int getday()
{
return day;
}
void showdata();
void setdata(int y,int m,int d);
};
data::data()
{
year=month=day=0;
}
void data::showdata()
{
cout<<year<<"年"<<month<<"月"<<day<<"日"<<endl;
}
void data::setdata(int y,int m,int d)
{
year=y;month=m;day=d;
}
class employee
{
private:
int num;
char *name;
data birth;
public:
employee();
~employee();
void print();
void setemp(char *na,int n,int y,int m,int d);
int isbirth(data a,employee b);
};
employee::employee():birth()
{
name=new char[10];
strcpy(name," ");
num=0;
}
employee::~employee()
{
delete [] name;
}
void employee::setemp(char *na,int n,int y,int m,int d)
{
delete [] name;
name=new char[strlen(na)+1];
strcpy(name,na);
num=n;
birth.setdata(y,m,d);
}
void employee::print()
{
cout<<"雇员"<<name<<"编号为"<<num<<",";
cout<<"出生日期为:";
birth.showdata();
}
int employee::isbirth(data a,employee b)
{
if(a.getyear()==b.birth.getyear()&&a.getmonth()==b.birth.getmonth()&&a.getday()==b.birth.getday())
return 1;
else return 0;
}
void main()
{
char b[10];
int n,y,m,d;
data da;
employee a;
cout<<"请输入现在的日期为:";
cin>>y>>m>>d;
da.setdata(y,m,d);
cout<<"今天的日期为:";
da.showdata();
cout<<"请输入雇员的姓名、编号以及生日:";
cin>>b;
cin>>n>>y>>m>>d;
a.setemp(b,n,y,m,d);
a.print();
if(a.isbirth(da,a)==1)
cout<<"今天是他的生日";
else cout<<"今天不是他的生日";
}
为什么每次运行都会跳出窗口提示Debug assertion failad?
求求各位大侠帮帮忙啊!!!!在此,先谢谢大家咯