64,654
社区成员
发帖
与我相关
我的任务
分享
PWORD tmpPwd = NULL;
DWORD d = 4666;
tmpPwd = (PWORD)(&d);
//if (tmpPwd)
//{
//delete(tmpPwd);
//tmpPwd = NULL;
//}
#include<iostream>
using std::cout;
using std::endl;
int main()
{
int a = 0;
char * b = new(&a)char; // code 1
*b = 123;
cout << *b << ' ' << a << endl;
b = NULL;
int * c = new int(456); // code 2
cout << *c << endl;
delete c;
c = NULL;
return 0;
}
PWORD tmpPwd= NULL;
0041139E mov dword ptr [tmpPwd],0
int d = 4666;
004113A5 mov dword ptr [d],123Ah
tmpPwd = (PWORD)(&d);
004113AC lea eax,[d]
004113AF mov dword ptr [tmpPwd],eax
tmpPwd与d指向同一块内存,delete tmpPwd 等于删除变量d。所以tmpPwd不用释放