??????c++???????????????????п???????????????????????????????????????????????????????????????????

??????????????????X????????????????忽??????????c++??????£?

class X {
private:
    int i;
    int j;
};

int main() {
    X x1;//????????x1
    X x2 = x1;//??x1??????x2
}

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

_main    PROC

; 7    : int main() {

    push    ebp
    mov    ebp?? esp
    sub    esp?? 16                    ; ?????x1??x2???16byte??????

; 8    :     X x1;//????????x1
; 9    :     X x2 = x1;//??x1??????x2

    mov    eax?? DWORD PTR _x1$[ebp];??x1?????????????????????eax?????x1?е???????i?????eax
    mov    DWORD PTR _x2$[ebp]?? eax;??eax??????д??x2????????????eax??????д??x2????????i
    mov    ecx?? DWORD PTR _x1$[ebp+4];?????x1????4byte??????????????????eax??????x1?е???????j?????ecx
    mov    DWORD PTR _x2$[ebp+4]?? ecx;??ecx??????д?????x2????4byte????????棬????ecx??????д??x2????????j

; 10   : }

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

?????????????????????????????к?????????????е?????????????????????????????????ɡ?????????????????????????????????????????????????????????????????????

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

????????????????????X???溬????????????

????c++???

class X {
private:
    int i;
    int j;
public:
    virtual ~X() {}//??????????
};

int main() {
    X x1;//????????x1
    X x2 = x1;//??x1??????x2
}

???????????????????????????????????????main???????????????????

????????????????main??????????

_main    PROC

; 9    : int main() {

    push    ebp
    mov    ebp?? esp
    sub    esp?? 24                    ; ???????????麯??????????????????12byte ???????i??j8byte vptr???4byte ????????x1 x2???24byte

; 10   :     X x1;//????????x1

    lea    ecx?? DWORD PTR _x1$[ebp];???x1????????????ecx??????ù????????????????????this
    call    ??0X@@QAE@XZ;???ù?????

; 11   :     X x2 = x1;//??x1??????x2

    lea    eax?? DWORD PTR _x1$[ebp];???x1????????????????eax
    push    eax;??eax??????????????????????
    lea    ecx?? DWORD PTR _x2$[ebp];???x2????????????????ecx?????????????????????????????????this
    call    ??0X@@QAE@ABV0@@Z;?????????????

; 12   : }

    lea    ecx?? DWORD PTR _x2$[ebp];???x2????????????ecx??????????????????????????????????????this
    call    ??1X@@UAE@XZ                ; ????????????
    lea    ecx?? DWORD PTR _x1$[ebp];???x1????????????ecx??????????????????????????????????????this
                                ;????????????????????
    call    ??1X@@UAE@XZ                ; ????????????
    xor    eax?? eax
    mov    esp?? ebp
    pop    ebp
    ret    0
_main    ENDP