Roger Luo

超越梦想一起飞
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2012年12月18日

摘要: Windows平台下的内存泄露使用CRTDBG#ifdef _DEBUG #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) #else #define DEBUG_CLIENTBLOCK #endif #define _CRTDBG_MAP_ALLOC #include <crtdbg.h> #ifdef _DEBUG #define new DEBUG_CLIENTBLOCK int main() { char * p = new char[10]; _CrtMemDumpAllObjectsSin 阅读全文

posted @ 2012-12-18 21:57 Roger Luo 阅读(309) 评论(0) 推荐(0) 编辑

摘要: std::inistializer_list使用inistializer_list能够初始化同一类型或者能够隐式转换成统一类型的函数形参,简化函数接口的实行,例如:double Sum(std::initializer_list<double>li) { double sum = 0.0; for(auto p = li.begin(); p != li.end(); p++) { sum += *p; } return sum; }这样调用函数的方式可以是多个参数: cout<<Sum({1.2})<<endl; cout<<Sum(... 阅读全文

posted @ 2012-12-18 14:36 Roger Luo 阅读(461) 评论(0) 推荐(0) 编辑