Main.cpp
" Prototype.h " <iostream>usingnamespace std; int Main (intChar *argv[]) { new concreateprototype (); *p1 = p->Clone (); return 0 ;}
Prototype.h
#ifndef _prototype_h#define_prototype_hclassPrototype { Public : Virtual~Prototype (); VirtualPrototype *clone ()Const=0;protected: Prototype ();};classConcreateprototype: PublicPrototype { Public: Concreateprototype (); Concreateprototype (ConstConcreateprototype &CP); ~Concreateprototype (); Prototype*clone ()Const;};#endif
Prototype.cpp
#include"Prototype.h"#include<iostream>using namespacestd; Prototype::P rototype () {}prototype::~Prototype () {}prototype*prototype::clone ()Const { return 0;} Concreateprototype::concreateprototype () {}concreateprototype::~Concreateprototype () {}concreateprototype::concreateprototype (ConstConcreateprototype &CP) {cout<<"Concreateprototype ..."<<Endl;} Prototype*concreateprototype::clone ()Const { return NewConcreateprototype (* This);}
"Design pattern" Prototype pattern