
c++设计模式
人生如白驹过隙
云朵公司董事长
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
c++工厂模式
//解决了简单工厂模式违背了开闭原则的问题// ConsoleApplication1.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include //#include "Factory.h"using namespace std;原创 2015-10-02 17:44:23 · 669 阅读 · 0 评论 -
c++中介者模式
#include "stdafx.h"#include #include using namespace std;typedef string State;class Colleague;class Mediator{public: virtual void AToB() = 0; virtual void BToA() = 0; virtual void IntroC原创 2015-10-21 21:24:52 · 423 阅读 · 0 评论 -
c++享元模式
#include "stdafx.h"#include #include #include #include #include using namespace std;enum Color {WHITE, BLACK, GRAY};struct Position{ int cx; int cy;};bool cmp(const Position& Fist, con原创 2015-10-06 12:10:00 · 460 阅读 · 0 评论 -
c++代理模式
#include "stdafx.h"#include using namespace std;class Subject{public: virtual void display() = 0;};class ConcreteSubject:public Subject{public: void display() {coutdisplay(); } ~Proxy() {delete m_pSub原创 2015-10-09 23:17:36 · 412 阅读 · 0 评论 -
c++原型模式
#include "stdafx.h"#include using namespace std;class Prototype{public:virtual Prototype* clone() const = 0;virtual int GetScore() const = 0;virtual void SetScore(int& temp) =原创 2015-10-04 10:43:41 · 352 阅读 · 0 评论 -
c++建造者模式
// ConsoleApplication1.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <iostream>//#include "Factory.h"using namespace std;class Man{public: Man():flag(原创 2015-10-04 10:40:22 · 432 阅读 · 0 评论 -
c++装饰模式
#include "stdafx.h"#include #include using namespace std;class Component{public: virtual void Method() = 0;};class ConcreteComponent:public Component{public: void Method();};void Con原创 2015-10-05 13:43:56 · 395 阅读 · 0 评论 -
c++对象适配器
// ConsoleApplication1.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include //#include "Factory.h"using namespace std;class Target{public原创 2015-10-03 17:04:15 · 455 阅读 · 0 评论 -
c++外观模式
#include "stdafx.h"#include using namespace std;class FunA{public: void display() {cout<<"FunA is working"<<endl;}};class FunB{public: void display() {cout<<"FunB is working"<<endl;}};原创 2015-10-04 13:10:55 · 650 阅读 · 0 评论 -
c++桥接模式
#include "stdafx.h"#include using namespace std;class SoftWare{public: virtual void display() = 0;};class SoftWareA:public SoftWare{ void display() {cout<<"soft a was finished"<<endl;}};原创 2015-10-04 12:06:10 · 469 阅读 · 0 评论 -
c++类适配器
// ConsoleApplication1.cpp : Defines the entry point for the console application.//Target生成对象是合理的,so不用纯虚函数#include "stdafx.h"#include //#include "Factory.h"using namespace std;原创 2015-10-03 16:57:28 · 408 阅读 · 0 评论 -
c++组合模式和原型模式一起使用
#include "stdafx.h"#include #include using namespace std;class Component{public: virtual Component* clone() = 0; virtual void operation() = 0; virtual void Add(Component* pComponent) {} vir原创 2015-10-04 23:46:40 · 418 阅读 · 0 评论 -
无名
人生是个什么东西原创 2015-10-04 00:07:02 · 329 阅读 · 0 评论 -
c++简单工厂模式
// ConsoleApplication1.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include //#include "Factory.h"using namespace std;class Product{p原创 2015-10-01 21:17:33 · 395 阅读 · 0 评论 -
c++单例模式(线程安全)
1.构造函数为private,生成对象的时候,编译器调用构造函数属于外部调用。2.构造函数为private不能被继承,因为当其子类初始化的时候需要调用构造函数,但此时构造函数为private,不能被调用。所以,该类只有一个实例。静态实例初始化在程序开始时进入主函数之前就由主线程以单线程方式完成了初始化,不必担心多线程问题。原创 2015-10-01 16:39:49 · 440 阅读 · 0 评论 -
c++抽象工厂模式
// ConsoleApplication1.cpp : Defines the entry point for the console application.// 这是违背开放封闭原则的:增加产品需修改工厂类#include "stdafx.h"#include //#include "Factory.h"using namespace std;原创 2015-10-02 22:01:56 · 545 阅读 · 0 评论 -
(转)第零章 序 我的云朵小姐 又名 孤独的程序员
我叫段蔚,一名程序员。她叫李芸。我想讲一个正在发生着的故事。转载 2015-10-09 08:11:34 · 376 阅读 · 0 评论