码迷,mamicode.com
首页 >  
搜索关键字:ptr    ( 2121个结果
Command
#include using namespace std;#define DESTROY_POINTER(ptr) if (ptr) { delete ptr; ptr = NULL; }class Receiver{public: void Action1() { coutAction1()...
分类:其他好文   时间:2014-12-17 12:41:41    阅读次数:126
C++模板 - policy类
一讲到traits,相应的就会联系到policy。那么policy是干啥的呢? 看一下下面的累加代码。 template typename traits::AccuT accum(const T* ptr, int len) { traits::AccuT total = traits::Zero(); for (int i = 0; i < len; i++) { total +...
分类:编程语言   时间:2014-12-16 19:14:24    阅读次数:188
C++模板 - traits
traits是个很好玩的东西,在泛型编程里面很常见。最早出于老外的一篇论文。http://www.cantrip.org/traits.html?seenIEPage=1 建议仔细阅读。   首先我们来看一段代码。 template T accum(const T* ptr, int len) { T total = T(); for (int i = 0; i < len; i++)...
分类:编程语言   时间:2014-12-16 17:10:33    阅读次数:270
State
#include using namespace std;#define DESTROY_POINTER(ptr) if (ptr) { delete ptr; ptr = NULL; }class Context;class DbState{public: DbState(Context* ...
分类:其他好文   时间:2014-12-16 13:25:30    阅读次数:173
C++11显式转换操作符
C++11之前,已经支持显式转换操作符 #include using namespace std; template class Ptr { public: Ptr(T* p): _p(p) {} operator bool() const { if (_p != 0) return true; else ...
分类:编程语言   时间:2014-12-15 17:23:54    阅读次数:169
Observer
#include #include using namespace std;#define DESTROY_POINTER(ptr) if (ptr) { delete ptr; ptr = NULL; }class Observer{public: virtual void Update(s...
分类:其他好文   时间:2014-12-15 13:27:40    阅读次数:112
Template_Method
#include using namespace std;#define DESTROY_POINTER(ptr) if (ptr) { delete ptr; ptr = NULL; }class TemplateMethod{public: void AlgorithmA() { Step...
分类:其他好文   时间:2014-12-15 10:19:26    阅读次数:138
c++11 stl 学习之 shared_ptr
shared_ptr智能指针 shared_ptr 的声明初始化方式由于指针指针使用explicit参数 必须显示声明初始化shared_ptr pNico = new string("nico"); // ERRORshared_ptr pNico{new string("nico")}; // ...
分类:编程语言   时间:2014-12-12 16:19:11    阅读次数:419
Flyweight
#include #include using namespace std;#define SHARE_FLAG string#define DESTROY_POINTER(ptr) if (ptr) { delete ptr; ptr = NULL; }class Flyweight{public...
分类:其他好文   时间:2014-12-12 14:39:48    阅读次数:155
Composite
#include #include using namespace std;#define DO_NOTHING()#define DESTROY_POINTER(ptr) if (ptr) { delete ptr; ptr = NULL; }class Component{ friend ...
分类:其他好文   时间:2014-12-12 11:15:31    阅读次数:133
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!