摘要: 当两个系统的接口不一样时,我们就要重新封装一下接口,以便于当前系统的调用。这种模式叫做适配器模式。适配器模式分为两种:1.对象组合适配器(Object Adapter)2.类适配器(Class Adapter)采用类继承的方式实现。下面是对象适配器的使用。#include #include using namespace std;class CCnOutlet{public: virtual ~CCnOutlet() { }; virtual void Cnplug() { //cout EnPlug(); }private: CEnOu... 阅读全文
posted @ 2013-12-16 16:08 onlycxue 阅读(3363) 评论(0) 推荐(0) 编辑
摘要: 原型模式是通过已经存在的对象的接口快速方便的创建新的对象。#include #include using namespace std;class Prototype{public: virtual Prototype *Clone() = 0; virtual void display() = 0;};class Prototype1:public Prototype{protected: string name; int id;public: Prototype1(string name, int id) { this->name = n... 阅读全文
posted @ 2013-12-16 14:29 onlycxue 阅读(949) 评论(0) 推荐(0) 编辑