拷贝构造函数问题
#include<iostream>#include<stdlib.h>
using namespace std;
class date
{
private:
int year;
int month;
int day;
public:
date()
{
year=0;month=0;day=0;
}
inline void birth()
{
cout<<"the birthday"<<endl;
cout<<"please input the year:";
cin>>year;
cout<<"please input the month:";
cin>>month;
cout<<"please input the day:";
cin>>day;
}
inline void print2()
{
cout<<year<<"."<<month<<"."<<day<<endl;
}
~date()
{}
};
class people
{
private:
long int number;
char sex;
char id[20];
public:
date b1;
people()
{
number=0;sex='\0';
}
inline void xinxi()
{
cout<<"please input the number:";
cin>>number;
cout<<"please input the sex:(m/f)";
cin>>sex;
cout<<"please input the id:";
cin>>id;
b1.birth();
}
inline void print1()
{
cout<<number<<endl
<<sex<<endl
<<id<<endl;
b1.print2();
}
~people()
{}
};
int main()
{
int i,n;
system("color 9e");
people p1[1000];
cout<<"How many people?";
cin>>n;
for(i=0;i<n;i++)
{
p1[i].xinxi();
}
for(i=0;i<n;i++)
{
p1[i].print1();
}
return 0;
}
怎样加拷贝构造函数