prototype.h

来自「常见设计模式的解析和实现,c++实现,经典的设计模式解析源码」· C头文件 代码 · 共 47 行

H
47
字号
/********************************************************************
	created:	2006/07/20
	filename: 	Prototype.h
	author:		李创
                http://www.cppblog.com/converse/

	purpose:	Prototype模式的演示代码
*********************************************************************/

#ifndef PROTOTYPE_H
#define PROTOTYPE_H

// 虚拟基类,所有原型的基类,提供Clone接口函数
class Prototype
{
public:
	Prototype(){}
	virtual ~Prototype(){}

	virtual Prototype* Clone() = 0;
};

// 派生自Prototype,实现Clone方法
class ConcreatePrototype1
	: public Prototype
{
public:
	ConcreatePrototype1();
	ConcreatePrototype1(const ConcreatePrototype1&);
	virtual ~ConcreatePrototype1();

	virtual Prototype* Clone();
};

// 派生自Prototype,实现Clone方法
class ConcreatePrototype2
	: public Prototype
{
public:
	ConcreatePrototype2();
	ConcreatePrototype2(const ConcreatePrototype2&);
	virtual ~ConcreatePrototype2();

	virtual Prototype* Clone();
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?