newwy
奋斗在IT路上的小蜗牛。一步一步往上爬,爬到小牛,在到大牛,然后是神牛,然后是犇,然后就可以离开IT行业,回归大自然了。 远离IT,珍爱生命!!! 记录学习的点滴。
/*********************************
*设计模式--原型模式实现
*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;
}

posted on 2010-10-18 23:55  newwy  阅读(322)  评论(0编辑  收藏  举报