2012年10月9日

摘要: Using C++ templatesIn C++, you can use a template to declare a set of related:Classes (including structures)FunctionsStatic data members of template classesWithin an application, you can instantiate the same template multiple times with the same arguments or with different arguments. If you use the 阅读全文
posted @ 2012-10-09 15:21 山本二十八 阅读(239) 评论(0) 推荐(0) 编辑
摘要: placement new是重载operator new的一个标准、全局的版本,它不能被自定义的版本代替(不像普通的operator new和operator delete能够被替换成用户自定义的版本)。它的原型如下:void *operator new( size_t, void *p ) throw() { return p; }首先我们区分下几个容易混淆的关键词:new、operator new、placement newnew和delete操作符我们应该都用过,它们是对堆中的内存进行申请和释放,而这两个都是不能被重载的。要实现不同的内存分配行为,需要重载operator new,而不是 阅读全文
posted @ 2012-10-09 09:45 山本二十八 阅读(156) 评论(0) 推荐(0) 编辑

导航