#include "stdafx.h"
class Test
{
public:
int _a;
Test(int a) : _a(a) {}
Test()
{
this->Test::Test(0); //结果正确
Test(0); //结果错误,_a 随机
*this = Test(0); //正确,但产生临时对象
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Test obj;
printf("%d \r\n",obj._a);
return 0;
}
this->Test::Test(0); //汇编
{
this->Test::Test(0);
00BD1483 push 0
00BD1485 mov ecx,dword ptr [this]
00BD1488 call Test::Test (0BD101Eh)
}
Test(0);//汇编
{
Test(0);
00031483 push 0
00031485 lea ecx,[ebp-0D4h]
0003148B call Test::Test (3101Eh)
}