设计模式
文章平均质量分 75
酷兒
这个作者很懒,什么都没留下…
展开
-
设计模式学习2--策略模式(商场管理软件)
#pragma once//抽象算法类class CCashSuper{public: CCashSuper(void); ~CCashSuper(void); virtual double AlgorithmInterface(double sum){return 0;}};//正常收费算法类class CashNormal : public CCashSuper{原创 2013-02-20 16:37:10 · 327 阅读 · 0 评论 -
设计模式学习1----工厂模式(计算器)
#include "stdafx.h"#include using namespace std;class Operation{public: double GetNumA(){return m_numberA;} double GetNumB(){return m_numberB;} void SetNumA(double value){m_numberA = value;}原创 2013-02-19 10:00:15 · 289 阅读 · 0 评论 -
设计模式学习3--装饰模式()
#include "stdafx.h"#include #include using namespace std;class Person//ConcreteComponent类{public: Person(){} Person(string strName) { m_strName = strName; } virtual void Show() { cout<原创 2013-02-26 10:27:47 · 262 阅读 · 0 评论 -
设计模式学习4--代理模式
#include "stdafx.h"#include #include using namespace std;class SchoolGirl{public: SchoolGirl(string name){m_name = name;} string m_name;};//interfaceclass Givegift{ virtual void GiveDol原创 2013-02-26 13:48:55 · 253 阅读 · 0 评论 -
设计模式学习6--外观模式
#include "stdafx.h"#include using namespace std;class SubSystemOne{public: void MethodOne(){cout<<"子系统方法一\n";}};class SubSystemTwo{public: void MethodTwo(){cout<<"子系统方法二\n";}};class SubSy原创 2013-03-13 11:09:29 · 583 阅读 · 0 评论 -
设计模式学习5--模版方法模式
模版方法模式是通过把不变行为搬到基类中,去除子类中重复代码来体现它的优势;模版方法模式提供了一个很好的代码复用平台;适用于:当不变的或者可变的行为在方法的子类实现中混合在一起的时候,不变的行为就会在子类中重复出现,我们通过模版方法模式把这些行为搬到基类中,就拜托了子类中重复的不变行为;原创 2013-03-12 16:33:00 · 495 阅读 · 0 评论