#include <iostream>
using namespace std;
class Student
{
protected:
int id;
char name[10];
public:
Student()
{
}
~Student()
{
cout<<"Desconstuct...."<<endl;
}
virtual Student *Clone()
{}
virtual void Show()
{ }
};
class StudentTypeA:public Student
{
public:
StudentTypeA(const char *name_input)
{
strcpy(name, name_input);
this->id = 0;
cout<<"Construction....."<<endl;
}
StudentTypeA(const StudentTypeA&other)
{
cout<<"Copy Construction..."<<endl;
this->id = other.id;
this->id ++;
strcpy(this->name, other.name);
}
virtual StudentTypeA *Clone()
{
StudentTypeA *tmp = new StudentTypeA(*this);
return tmp;
}
void Show()
{
cout<<"Student id == "<< id << " name == "<< name <<endl;
}
~StudentTypeA()
{
cout<<"Deconstruction StudentTypeA"<<endl;
}
};
int main()
{
Student *student1 = new StudentTypeA("fulima");
Student *student2 = student1->Clone();
Student *student3 = student2->Clone();
student1->Show();
student2->Show();
student3->Show();
return 0;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有