/ * Directory: a pointer to this principle * /
A pointer to this principle
class CTest { public: CTest(int nNum) { this->nNum = nNum; } ~CTest() { } void Print() { cout << nNum << endl; } private: int nNum; }; int main(int argc, char *argv[], char **envp) { CTest c(0x11); c.Print(); return 0; } // disassembly // call the function int main ( int argc, char * the argv [], char ** envp) { 136 : CTest C ( 0x11 ); 0041A8BD Push 11H 0041A8BF LEA ECX, [C] @ obtaining address: ecx - address of the variable c 0041A8C2 Call CTest :: CTest (0411983h) 0041A8C7 DWORD PTR MOV [EBP - . 4 ], 0 return 0 ; } // do not transfer function 114 : class CTest 115 : { 1 16 : public : 117 : CTest ( int nNum) 004122F0 Push EBP 004122F1 MOV EBP, ESP 004122F3 Sub ESP, 0CCh 004122F9 Push EBX 004122FA Push ESI 004122FB Push EDI 004122FC Push ECX // push Parameters: ecx - address variable c 004122FD lea edi , [EBP 0CCh] 00,412,303 mov ECX, 33h 00,412,308 mov eax, 0CCCCCCCCh 0041230D REP STOS DWORD ptr es: [EDI] 0041230F POP ECX // the stack parameters: ecx - address variable c 00.41231 million MOV DWORD PTR [ this ], ECX // parameter assignment: ecx - Hide this pointer variable; this case the function pointer to the variable c mian address. 1 18 : { 119 : the this -> nNum = nNum; 00,412,313 MOV EAX, DWORD PTR [ the this ] 00,412,316 MOV ECX, DWORD PTR [nNum] 00,412,319 MOV DWORD PTR [EAX], ECX 120 :} }