12 2011 档案
模板方法模式
摘要:定义一个操作中的算法的骨架,而将一些步骤延迟到子类中。模板方法使得子类可以不改变算法的结构即可重定义该算法的某些特定步骤。// TemplateMethod.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <iostream>using namespace std;class ITemplateMethod{public:virtual void TemplateMethod(){OperaterMethod1();OperaterMe 阅读全文
posted @ 2011-12-13 17:41 Just a Programer 阅读(151) 评论(0) 推荐(0)
代理模式
摘要:代理模式:为其他对象提供一种代理以控制对这个对象的访问。// Proxy.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <iostream>using namespace std;class ISubject{public:virtual void doSomething() = 0;};class ConcreateSubject: public ISubject{public:virtual void doSomething(){ 阅读全文
posted @ 2011-12-02 16:26 Just a Programer 阅读(228) 评论(0) 推荐(0)
装饰模式
摘要:装饰模式, 动态地给一个对象添加一些额外的职责,就增加功能来说,装饰模式比生成子类更为灵活。// Decorator.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <iostream>using namespace std;class IComponent{public:virtual void process() = 0;};class Component : public IComponent{public:virtual voi 阅读全文
posted @ 2011-12-01 17:31 Just a Programer 阅读(224) 评论(0) 推荐(0)