#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;
}

相关文章:

  • 2021-08-21
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2021-11-27
猜你喜欢
  • 2021-10-11
  • 2021-07-27
  • 2021-06-05
  • 2022-12-23
  • 2021-11-20
  • 2021-04-28
相关资源
相似解决方案