设计模式 - Prototype
意图:提供一个通过拷贝已存在对象进行新对象创建的接口。
class Prototype { public: Prototype() {} virtual ~Prototype() {} virtual Prototype* Clone() = 0; }; class ConcretePrototype: public Prototype { public: ConcretePrototype(const string& str) { this->content = str; } ConcretePrototype(const ConcretePrototype& cp) { this->content = cp.content; } ~ConcretePrototype() {} Prototype* Clone() { return new ConcretePrototype(*this); } private: string content; };