#include "stdafx.h"
#include <windows.h>
#define _CRTDBG_MAP_ALLOC
#include "crtdbg.h"
#define _DEBUG
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#ifdef _DEBUG
#ifndef DEBUG_NEW
#define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__)
#endif
#endif
class X
{
public:
X::X() : m_value(123) {}
private:
int m_value;
};
void test()
{
X *p1 = 0;
X *p2 = 0;
X *p3 = 0;
p1 = new X();
p2 = new X();
p3 = new X();
delete p1;
delete p3;
}
int _tmain(int argc, _TCHAR* argv[])
{
char temp[20];
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
test();
_CrtDumpMemoryLeaks();
return 0;
}
沒有留言:
張貼留言