??????????м?й??????????????γ????vptr??????

??????????c++???

class X {
private:
    int i;
public:
    virtual void f() {}
};

class Y : public X {//Y?????X
private:
   int j;
};

 


int main() {
 Y y;
}

??????????main?????е?????

_main    PROC

; 16   : int main() {

    push    ebp
    mov    ebp?? esp
    sub    esp?? 12                    ; ?????y???12 byte???? vptr???4byte ??????????4byte ??????????4byte

; 17   :  Y y;

    lea    ecx?? DWORD PTR _y$[ebp];???????y??????(??this???)????????????????????????
    call    ??0Y@@QAE@XZ;????y??????? ???y?????????幹?????????????京????????????????????????????

; 18   : }

    xor    eax?? eax
    mov    esp?? ebp
    pop    ebp
    ret    0
_main    ENDP

???????????????????????

??0Y@@QAE@XZ PROC                    ; Y::Y?? COMDAT
; _this$ = ecx
    push    ebp
    mov    ebp?? esp
    push    ecx;//??ecx?????????this???
    mov    DWORD PTR _this$[ebp]?? ecx;??this???(??????????)??????????? ecx?????????????
    mov    ecx?? DWORD PTR _this$[ebp];????????????ecx ????????????????????????
    call    ??0X@@QAE@XZ;???????????
    mov    eax?? DWORD PTR _this$[ebp];??y?????????????eax
    mov    DWORD PTR [eax]?? OFFSET ??_7Y@@6B@;??y??vtable(??_7Y@@6B@)????????y?????????????? ???????????vptr???
    mov    eax?? DWORD PTR _this$[ebp];??y??????eax????????????????????????????????
    mov    esp?? ebp
    pop    ebp
    ret    0
??0Y@@QAE@XZ ENDP

??????????????????????

??0X@@QAE@XZ PROC                    ; X::X?? COMDAT
; _this$ = ecx
    push    ebp
    mov    ebp?? esp
    push    ecx;??????????????this???(?????????????)?????
    mov    DWORD PTR _this$[ebp]?? ecx;???????????????(ecx?б???)???????????
    mov    eax?? DWORD PTR _this$[ebp];???????????????????eax
    mov    DWORD PTR [eax]?? OFFSET ??_7X@@6B@;??vtable(??_7X@@6B@ ???????)????????????????????????? ??????????????vptr???
    mov    eax?? DWORD PTR _this$[ebp];?????????????????eax????????????????????????????????
    mov    esp?? ebp
    pop    ebp
    ret    0
??0X@@QAE@XZ ENDP

????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????ecx??????????????????????????????????vptr???λ??????????????????????????У?vptr???????????????????vtable??????????????????У???????????????????????vtable????????????????????У??????????漰??е????vptr???????????????????????