2012年7月19日

decorator模式

摘要: 1 #include <iostream> 2 using namespace std; 3 4 class compoent 5 { 6 public: 7 compoent(){} 8 virtual ~compoent(){} 9 10 virtual void Operation(){};11 };12 13 class concretecompoent:public compoent{14 virtual void Operation(){cout<<"I can only do AAAAAAAAAAAAAA!!!!\n";};15 16 阅读全文

posted @ 2012-07-19 16:23 kakamilan 阅读(169) 评论(0) 推荐(0) 编辑

adapter模式

摘要: 1 #include <iostream> 2 using namespace std; 3 4 class target 5 { 6 public: 7 target(){} 8 virtual ~target(){} 9 10 virtual void Operation(){};11 };12 13 class adaptee{14 public:15 void special_work(){16 cout<<"only I can do!!\n";17 }18 };19 20 21 /*类适配器模式22 * 优点:可以重定义... 阅读全文

posted @ 2012-07-19 12:40 kakamilan 阅读(220) 评论(0) 推荐(0) 编辑

bridge模式

摘要: 看了好几天,一直没想明白bridge模式到底怎么用,知道今天把四人帮的书翻出来,看到这样一句话,才恍然大悟,敲出来记录一下。“一般来讲,Implementor接口仅提供基本操作,而Abstraction则定义了基于这些基本操作的较高层次的操作。” 1 #include <iostream> 2 using namespace std; 3 4 5 // 为实现Abstraction定义的抽象基类,定义了实现的接口函数 6 class Implementor 7 { 8 public: 9 Implementor(){}10 virtual ~Implementor(){}1... 阅读全文

posted @ 2012-07-19 10:34 kakamilan 阅读(151) 评论(0) 推荐(0) 编辑

导航