扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
using namespace System;
ref class Foo
{
public:
Foo()
{
System::Console::WriteLine("Foo::Foo");
}
~Foo()
{
System::Console::WriteLine("Foo::~Foo");
}
public:
int m_iValue;
};
int _tmain()
{
int* pInt = new int;
int^ rInt = gcnew int;
Foo^ rFoo = gcnew Foo;
delete rFoo;
delete rInt;
delete pInt;
} |
int* pInt = new int;
0000004c mov ecx,4
00000051 call dword ptr ds:[03B51554h]
00000057 mov esi,eax
00000059 mov dword ptr [esp+18h],esi
int^ rInt = gcnew int;
0000005d mov ecx,788EF9D8h
00000062 call FCFAF66C
00000067 mov esi,eax
00000069 mov dword ptr [esi+4],0
00000070 mov edi,esi
Foo^ rFoo = gcnew Foo;
00000072 mov ecx,3B51768h
00000077 call FCFAF66C
0000007c mov esi,eax
0000007e mov ecx,esi
00000080 call dword ptr ds:[03B517ACh]
00000086 mov dword ptr [esp+1Ch],esi
delete rFoo;
0000008a mov ebx,dword ptr [esp+1Ch]
0000008e test ebx,ebx
00000090 je 000000A4
00000092 mov ecx,ebx
00000094 call dword ptr ds:[03FD0028h]
0000009a mov dword ptr [esp+14h],0
000000a2 jmp 000000AC
000000a4 mov dword ptr [esp+14h],0
delete rInt;
000000ac mov edx,edi
000000ae mov ecx,788F747Ch
000000b3 call FC8D20FD
000000b8 mov ebp,eax
000000ba test ebp,ebp
000000bc je 000000D0
000000be mov ecx,ebp
000000c0 call dword ptr ds:[03FD0020h]
000000c6 mov dword ptr [esp+10h],0
000000ce jmp 000000D8
000000d0 mov dword ptr [esp+10h],0
delete pInt;
000000d8 mov ecx,dword ptr [esp+18h]
000000dc call dword ptr ds:[03B51540h]
|
int* pInt = new int;
0000004c mov ecx,4
00000051 call dword ptr ds:[03B51554h] |
int^ rInt = gcnew int;
0000005d mov ecx,788EF9D8h
00000062 call FCFAF66C
。。。
Foo^ rFoo = gcnew Foo;
00000072 mov ecx,3B51768h
00000077 call FCFAF66C |
0x00F73404 d8 f9 8e 78 00 00 00 00 。。。 |
delete pInt;
000000d8 mov ecx,dword ptr [esp+18h]
000000dc call dword ptr ds:[03B51540h]
比较简单,就是传入地址,然后调用operator delete来释放类存,会调用析构函数 |
delete rInt;
000000ac mov edx,edi
000000ae mov ecx,788F747Ch
000000b3 call FC8D20FD |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。