#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
struct A
{
A(char* p)
: p(p)
{}
~A()
{
delete this->p;
}
char* p;
};
int main()
{
A a(new char);
_CrtDumpMemoryLeaks();
}
在调试模式下运行后,Visual Studio 2012 的输出窗口显示:
Detected memory leaks!
Dumping objects ->
{142} normal block at 0x007395A8, 1 bytes long.
Data: < > CD
Object dump complete.
原因是什么?