麻烦V

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

2011年12月15日

摘要: Component是定义一个对象接口,可以给这些对象动态地添加职责。ConcreteComponent是定义了一个具体的对象,也可以给这个对象添加一些职责。Decorator,装饰抽象类,继承了Component,从外类来扩展Component类得功能,但对于Component来说,是无需知道Decorator的存在的。至于ConcreteComponent就是具体的装饰对象,起到给Component添加职责的功能。 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 class Co 阅读全文
posted @ 2011-12-15 22:21 麻烦V 阅读(165) 评论(0) 推荐(0)

摘要: 策略模式:定义了算法家族,分别封装起来,让它们之间可以互相替换,此模式让算法的变化,不会影响到使用算法的客户。 1 #include <iostream> 2 using namespace std; 3 4 //定义所有支持的算法的公共类 5 class Strategy 6 { 7 public: 8 virtual void AlgorithmInterface()=0; 9 };10 11 //封装了具体的算法或行为 继承于Strategy12 class ConcreteStrategyA : public Strategy13 {14 public:15 void... 阅读全文
posted @ 2011-12-15 18:33 麻烦V 阅读(155) 评论(0) 推荐(0)

2011年12月14日

摘要: 最近看了设计模式,收获很多,所以特记录下来以便以后学习用。毕竟书不是随时都带在身上的。#include <iostream>#include <string>using namespace std;class Operation{private: double _numberA ; double _numberB ;public: double GetNumberA(){return _numbe... 阅读全文
posted @ 2011-12-14 17:24 麻烦V 阅读(204) 评论(0) 推荐(0)