CTest::~CTest() { } void CTest::b() { printf("b is be called by a"); } void CTest::a(int one,int two) { printf("call b"); b(); } 下面是相应的反汇编代码: --- D:\myown\test\test.cpp ------------ 1: // test.cpp : Defines the entry point for the console application. 2: // 3: 4: #include "stdafx.h" 5: #include "CTest.h" 6: 7: int main(int argc, char* argv[]) 8: { 00401050 push ebp 00401051 mov ebp,esp 00401053 push 0FFh 00401055 push offset __ehhandler$_main (00410c89) 0040105A mov eax,fs:[00000000] 00401060 push eax 00401061 mov dword ptr fs:[0],esp 00401068 sub esp,48h 0040106B push ebx 0040106C push esi 0040106D push edi 0040106E lea edi,[ebp-54h] 00401071 mov ecx,12h 00401076 mov eax,0CCCCCCCCh 0040107B rep stos dword ptr [edi] 9: CTest aTest; 0040107D lea ecx,[ebp-10h] //这是用来保存aTest的this指针,因为是局部变量所以是保存在[ebp-10h]中 00401080 call @ILT+30(CTest::CTest) (00401023) //调用aTest的构造函数,由编译器自动产生的CALL 00401085 mov dword ptr [ebp-4],0 10: aTest.a(1,2); 0040108C push 2 0040108E push 1 00401090 lea ecx,[ebp-10h] //把aTest的this指针用ecx进行传递 00401093 call @ILT+5(CTest::a) (0040100a) 11: return 0;
|
正在阅读:C++类机制的实现细节C++类机制的实现细节
2004-04-23 10:17
出处:CSDN
责任编辑:linjixiong
键盘也能翻页,试试“← →”键