# include
# include
using namespace std;
class Student{
private:
char Id[20];
char Name[20];
char sex;
char birthday[9];
char* Pha;
public :
Student() //构造函数
{
strcpy(Id,"NoId");
strcpy(Name,"Noname");
sex='N';
strcpy(birthday,"19000101");
Pha=new char[13];
strcpy(Pha,"江苏理工学院");
};
void show();
~Student(){ //析构函数
delete []Pha;
cout<<"释放完成\n";
};
Student(Student &rgd) //深复制的复制构造函数
{
strcpy(this->Id,rgd.Id);
strcpy(this->Name,rgd.Name);
this->sex=rgd.sex;
strcpy(this->birthday,rgd.birthday);
this->Pha=new char[strlen(rgd.Pha)+1];
strcpy(this->Pha,rgd.Pha);
}
Student(char Id[],char Name[],char sex,char birthday[],char* Pha){
strcpy(this->Id,Id);
strcpy(this->Name,Name);
this->sex=sex;
strcpy(this->birthday,birthday);
this->Pha=new char[strlen(Pha)+1];
strcpy(this->Pha,Pha);
}
};
void Student::show()
{
cout<Id<
cout<Name<
cout<sex<
cout<birthday<
cout<Pha< }
int main()
{
Student stu1("440201199803243456","Minghao",'M',"19980324","江苏省常州市钟楼区中吴大道"); //构造函数
Student stu3;
stu1.show(); //输出函数
stu3.show(); //输出函数
Student stu2(stu1);
stu2.show(); //输出函数
return 0;
}