#include <string>
using namespace std;
class date
{
private:
int year ;
int month;
int day;
public :
date()
{
cout<<"构造函数";
};
void setDate(int y ,int m ,int d )
{
year=y;
month=m;
day=d;
};
date (date&bir)
{
year =bir.year ;
month=bir.month;
day=bir.day;
};
int getYear()
{
return year;
};
int getMonth()
{
return month;
};
int getDay()
{
return day;
};
};
class people
{
private:
date birthday;
int num;
char name[20];
char sex[4];
char id[20];
public :
people()
{
};
void input()
{
int y,m,d;
cout<<"录入数据";
cout<<"编号"<<endl;
cin>>num;
cout<<"姓名"<<endl;
cin>>name;
cout<<"性别"<<endl;
cin>>sex; //40
cout<<"身份证编号"<<endl;
cin>>id;
cout<<"出生日期(年月日)"<<endl;
cin>>y>>m>>d;
birthday.setDate(y,m,d);
};
void output()
{
cout<<"编号"<<num<<endl;
cout<<"姓名"<<name<<endl;
cout<<"性别"<<sex<<endl ;
cout<<"身份证编号"<<id<<endl;
cout<<"生日"<<birthday;
};
};
int main()
{
people p1;
p1.input();
p1.output();
return 0;
}
最后在output()方法里面输出birthday报错,该怎样修改?
本人C++小白,问下复制函数到底有什么用?以上面为例,把那个的复制函数去掉可否?
智慧大石
噜噜哒