#include <iostream>
using namespace std;
class prototype
{
public:
prototype(){cout<<"build prototype"<<endl;}
virtual ~prototype(){cout<<"unbuild prototype"<<endl;}
virtual prototype *clone()=0;
};
class subtype : public prototype
{
public:
subtype(){cout<<"build subtype"<<endl;}
subtype(prototype *pt){cout<<"build a subtype"<<endl;}
virtual ~subtype(){cout<<"unbuild subtype"<<endl;}
prototype *clone(){cout<<"clone"<<endl;return new subtype(*this);}
};
int main()
{
prototype *p1=new subtype;
prototype *p2=p1->clone();
delete p1;
delete p2;
system("pause");
return 0;
}