设计模式实现(六): Adapter Pattern
2011-02-16 20:12
162 查看
#include "stdafx.h" #include <iostream> class CAdaptee1 { public: void SpecificPrint() { std::cout << "specific print" << std::endl; } }; class CAdaptee2 { public: void SpecificPrint2() { std::cout << "specific print 2" << std::endl; } }; class CAdapter { public: virtual void Print() = 0; }; class CAdapter1 : public CAdapter { public: virtual void Print() { m_Adaptee.SpecificPrint(); } private: CAdaptee1 m_Adaptee; }; class CAdapter2 : public CAdapter { public: virtual void Print() { m_Adaptee.SpecificPrint2(); } private: CAdaptee2 m_Adaptee; }; int _tmain(int argc, TCHAR argv[]) { CAdapter1 Adapter1; CAdapter2 Adapter2; Adapter1.Print(); Adapter2.Print(); return 0; }
相关文章推荐
- 设计模式之适配器模式(Adapter Pattern)C++实现
- 我所理解的设计模式(C++实现)——适配器模式(Adapter Pattern)
- 设计模式之适配器模式(Adapter Pattern)C++实现
- 我所理解的设计模式(C++实现)——适配器模式(Adapter Pattern)
- 我所理解的设计模式(C++实现)——适配器模式(Adapter Pattern)
- 我所理解的设计模式(C++实现)——适配器模式(Adapter Pattern)
- Head First 设计模式 (七)适配器模式(adapter pattern) C++实现
- 我所理解的设计模式(C++实现)——适配器模式(Adapter Pattern)
- 我所理解的设计模式(C++实现)——适配器模式(Adapter Pattern)
- (二)二十三中设计模式之我见-----------------适配器模式(Adapter Pattern)
- C++设计模式八--AdapterPattern(适配器模式)
- 我所理解的设计模式(C++实现)——中介者模式(Mediator Pattern)
- 24种设计模式--适配器模式【Adapter Pattern】
- 设计模式-适配器模式(Adapter Pattern)
- 我所理解的设计模式(C++实现)——模板方法模式(Template Method Pattern)
- 设计模式--适配器模式(Adapter Pattern)
- 设计模式——行为型模式之通过中介者模式(Mediator Pattern)实现各模块之间的解耦(二)
- 我所理解的设计模式(C++实现)——建造者模式(Builder Pattern)
- 《设计模式--基于C#的工程化实现及扩展》补充 Security Design Pattern 系列 1 公钥体系与分布式环境要求
- 设计模式之工厂模式(Factory Pattern)用C++实现