摘要:一个简单的point坐标类 class Point {public: Point():xval(0),yval(0){} Point(int x,int y):xval(x),yval(y){} int x()const { return xval; } int y()const { return
阅读全文
摘要:单例模式 // Singleton.cpp: 定义控制台应用程序的入口点。// #include "stdafx.h"#include <iostream>#include <memory> using namespace std; template< typename T >class Singl
阅读全文
摘要:根据需求的不同 选择不同的策略算法 之前是保存的各种策略类的指针 这里直接使用 function bind 选择对应的算法 代码 // 005.cpp: 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <functional> #include <ios
阅读全文
摘要:参考http://blog.csdn.net/calmreason/article/details/51029285 定义一系列相同的算法 根据不同需求选择不同的算法策略 使用 bind function 见 设计模式 策略模式2 c++11 代码 // 004.cpp: 定义控制台应用程序的入口点
阅读全文
摘要:参考http://blog.csdn.net/calmreason/article/details/50909321 桥接模式 实现与抽象之间由指针关联 调用sample类 实际是调用sample类保存的实现类的方法 代码: // 003.cpp: 定义控制台应用程序的入口点。 // #includ
阅读全文
摘要:参考http://blog.csdn.net/calmreason/article/details/50903729 所有产品继承同一基本类 由工厂保存基类指针 产生各类产品 代码 // 002.cpp: 定义控制台应用程序的入口点。 // #include "stdafx.h" #include
阅读全文
摘要:设计模式 模板模式如果有一个流程如下step1();step2();step3();step4();step5();其中step3() step5()是需要用户自己编写使用其他步骤是固定的那么可以写成
阅读全文
摘要:关于学习 《深入应用c++11》的代码笔记:c++11之前是这么实现的templateclass Singleton{public: static T* Instance(){ if (m_pInstance == nullptr) m_pInstance = new T(); return...
阅读全文
摘要:设计模式中 最基本的工厂模式感觉就是根据输入的类型决定选择何种类与进行何种操作。跟面向过程中输入1则执行func1();输入2则执行func2()基本一致的想法#include using namespace std;enum eShoeType{ leather = 0,rubber};class...
阅读全文