经过测试发现,如果构造函数中抛出异常返回的话,最后,new返回的指针为NULL,测试代码如下:
#include "stdafx.h"
class A
{
public:
A()
{
m1 = 2;
m2 = 3;
throw 0;
}
private:
int m1;
int m2;
};
int _tmain(int argc, _TCHAR* argv[])
{
A* a = NULL;
try
{
a = new A();
}
catch(...)
{
}
getchar();
return 0;
}
断点下载getchar()上,可以看到a=0x00000000;