随笔分类 -  设计模式

c++沉思录 学习笔记 第六章 句柄(引用计数指针雏形?)
摘要:一个简单的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 阅读全文

posted @ 2017-11-14 09:22 itdef 阅读(242) 评论(0) 推荐(0) 编辑

设计模式 单例模式 使用模板及智能指针
摘要:单例模式 // Singleton.cpp: 定义控制台应用程序的入口点。// #include "stdafx.h"#include <iostream>#include <memory> using namespace std; template< typename T >class Singl 阅读全文

posted @ 2017-09-01 09:32 itdef 阅读(308) 评论(0) 推荐(0) 编辑

设计模式 策略模式2 c++11
摘要:根据需求的不同 选择不同的策略算法 之前是保存的各种策略类的指针 这里直接使用 function bind 选择对应的算法 代码 // 005.cpp: 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <functional> #include <ios 阅读全文

posted @ 2017-08-31 10:36 itdef 阅读(180) 评论(0) 推荐(0) 编辑

设计模式策略模式
摘要:参考http://blog.csdn.net/calmreason/article/details/51029285 定义一系列相同的算法 根据不同需求选择不同的算法策略 使用 bind function 见 设计模式 策略模式2 c++11 代码 // 004.cpp: 定义控制台应用程序的入口点 阅读全文

posted @ 2017-08-31 10:16 itdef 阅读(138) 评论(0) 推荐(0) 编辑

设计模式之桥接模式 c++11
摘要:参考http://blog.csdn.net/calmreason/article/details/50909321 桥接模式 实现与抽象之间由指针关联 调用sample类 实际是调用sample类保存的实现类的方法 代码: // 003.cpp: 定义控制台应用程序的入口点。 // #includ 阅读全文

posted @ 2017-08-31 10:10 itdef 阅读(191) 评论(0) 推荐(0) 编辑

设计模式 工厂模式 使用shared_ptr
摘要:参考http://blog.csdn.net/calmreason/article/details/50903729 所有产品继承同一基本类 由工厂保存基类指针 产生各类产品 代码 // 002.cpp: 定义控制台应用程序的入口点。 // #include "stdafx.h" #include 阅读全文

posted @ 2017-08-31 10:04 itdef 阅读(401) 评论(0) 推荐(0) 编辑

游戏编程模式
摘要:http://gpp.tkchu.me/ 阅读全文

posted @ 2016-12-31 21:53 itdef 阅读(158) 评论(0) 推荐(0) 编辑

设计模式之模板模式 template
摘要:设计模式 模板模式如果有一个流程如下step1();step2();step3();step4();step5();其中step3() step5()是需要用户自己编写使用其他步骤是固定的那么可以写成 阅读全文

posted @ 2016-08-26 20:15 itdef 阅读(247) 评论(0) 推荐(0) 编辑

c++11 改进设计模式 Singleton模式
摘要:关于学习 《深入应用c++11》的代码笔记:c++11之前是这么实现的templateclass Singleton{public: static T* Instance(){ if (m_pInstance == nullptr) m_pInstance = new T(); return... 阅读全文

posted @ 2015-06-28 22:56 itdef 阅读(1093) 评论(0) 推荐(0) 编辑

设计模式之工厂模式 练习
摘要:设计模式中 最基本的工厂模式感觉就是根据输入的类型决定选择何种类与进行何种操作。跟面向过程中输入1则执行func1();输入2则执行func2()基本一致的想法#include using namespace std;enum eShoeType{ leather = 0,rubber};class... 阅读全文

posted @ 2014-07-28 11:29 itdef 阅读(618) 评论(1) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示