/*********************************
*设计模式--原型模式实现
*C++语言
*Author:WangYong
*Blog:http://www.cnblogs.com/newwy
********************************/
#include <iostream>
using namespace std;
class Prototype
{
	public:
	virtual ~Prototype(){};
	virtual Prototype *Clone() const = 0;	
};
Prototype *Prototype::Clone()const{return 0;}
class ConcretePrototype:public Prototype
{
	public:
	ConcretePrototype(){};
	~ConcretePrototype(){};
	ConcretePrototype(const ConcretePrototype &cp)
	{
		cout<<"ConcretePrototype copy..."<<endl;
	}
	Prototype* Clone()const
	{
		return new ConcretePrototype(*this);	
	}
};
int main()
{
	Prototype *p = new ConcretePrototype();
	Prototype *p1 = p->Clone();
	return 0;
}

相关文章:

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