摘要:
使用MFC提供的功能来检测内存泄露。使用方法:1)工程是MFC工程,或是工程的设置中有Use MFC in a Shared DLL,2)很多地方说是要定义以下宏#ifdef _DEBUG#define new DEBUG_NEW#endif但是我发现只要include <afx.h> 即可。(大家可以检测一下)3)可以在F5运行程序后,在output窗口中看到如下的内存泄露的显示。(只在debug下有用哦)4)如果有泄露,则显示如下:Detected memory leaks!Dumping objects ->{214} normal block at 0x00D9161 阅读全文
posted @ 2012-07-04 21:42
Fcoding_狂人
阅读(768)
评论(0)
推荐(0)
摘要:
一Visual Studio 调试器和 C 运行时 (CRT) 库为我们提供了检测和识别内存泄漏的有效方法。主要使用函数:_CrtDumpMemoryLeaks();二 实例 1 #define _CRTDBG_MAP_ALLOC //输出更详细的report 2 #include <stdlib.h> 3 #include <crtdbg.h> 4 //以上的内容必须放在其他include的前面 5 6 #include <vector> 7 8 class MyClass 9 {10 private:11 int *p;12 public:13 MyCl 阅读全文
posted @ 2012-07-04 21:37
Fcoding_狂人
阅读(605)
评论(0)
推荐(0)
摘要:
一 拷贝构造函数是C++最基础的概念之一,大家自认为对拷贝构造函数了解么?请大家先回答一下三个问题:1. 以下函数哪个是拷贝构造函数,为什么?X::X(constX&); X::X(X); X::X(X&,inta=1); X::X(X&,inta=1,b=2);2. 一个类中可以存在多于一个的拷贝构造函数吗?3. 写出以下程序段的输出结果, 并说明为什么?如果你都能回答无误的话,那么你已经对拷贝构造函数有了相当的了解。#include #include structX{ template<typenameT> X(T&){std::cout< 阅读全文
posted @ 2012-07-04 21:07
Fcoding_狂人
阅读(389)
评论(0)
推荐(0)
摘要:
Debug Information to release dlls Text: There are 3 settings to add debug information to release dlls under project -> Properties. Make sure you change your Configuration to Release and set the following properties.Under Linker Properties ---> Debug ---> General Debug Info – Yes (/DEBUG) Ge 阅读全文
posted @ 2012-07-04 20:46
Fcoding_狂人
阅读(297)
评论(0)
推荐(0)