C++实现装饰者模式
2012-11-06 16:57
281 查看
/* 外观模式:为子系统的一组接口提供一个一致的界面, 此模式定义了一个高层接口,这个接口使得子系统更容易使用 */ #include <iostream> using namespace std; class TestA { public: void display_a() { cout<<"display a..."<<endl; } }; class TestB { public: void display_b() { cout<<"display b..."<<endl; } }; class Facade { TestA *testa; TestB *testb; public: Facade() { testa = new TestA(); testb = new TestB(); } ~Facade() { delete testa; delete testb; } void MethodA() { testa->display_a(); testb->display_b(); } }; int main() { Facade *facade = new Facade(); facade->MethodA(); system("pause"); return 0; }
相关文章推荐
- HeadFirst设计模式 之 C++实现(三):Decorator(装饰者模式)
- 最常用的设计模式---装饰者模式(C++实现)
- 自己写的用c++实现的简单装饰者模式
- HeadFirst设计模式 之 C++实现(三):Decorator(装饰者模式)
- 转florian大神blog之 - 从实现装饰者模式中思考C++指针和引用的选择
- 设计模式-装饰者模式 C++实现
- 装饰者模式C++实现——参考《Head First设计模式》
- 装饰者模式及C++实现
- 装饰者模式及C++代码实现
- 设计模式之装饰者模式 及 c++实现
- 我所理解的设计模式(C++实现)——装饰者模式(Decorator Pattern)
- Head First 设计模式 (三) 装饰者模式(decorator pattern) C++实现
- 设计模式C++实现——装饰者模式
- 装饰者模式C++实现
- 设计模式之C++实现(三)---装饰者模式(Decorator)
- 《Head First设计模式》之装饰者模式实例代码C++实现
- (C++实现)——装饰者模式(Decorator Pattern)
- Head First设计模式C++实现--第三章:装饰者(Decorator)模式
- 装饰者模式(Decorator)的c++实现示例
- 装饰者模式-c++实现