cout<<a+ ++a<<endl;//输出22
001017CF
mov
eax,dword ptr [a]
001017D2
add
eax,1
001017D5
mov
dword ptr [a],eax
001017D8
mov
esi,esp
001017DA
mov
ecx,dword ptr [__imp_std::endl (1082A8h)]
001017E0
push
ecx
001017E1
mov
edx,dword ptr [a]
001017E4
add
edx,dword ptr [a]
001017E7
mov
edi,esp
001017E9
push
edx
001017EA
mov
ecx,dword ptr [__imp_std::cout (1082A4h)]
001017F0
call
dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (1082A0h)]
001017F6
cmp
edi,esp
001017F8
call
@ILT+320(__RTC_CheckEsp) (101145h)
001017FD
mov
ecx,eax
001017FF
call
dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (10829Ch)]
00101805
cmp
esi,esp
00101807
call
@ILT+320(__RTC_CheckEsp) (101145h)
a=10;
0010180C
mov
dword ptr [a],0Ah
cout<<++a+ ++a<<endl;//输出24
00101813
mov
eax,dword ptr [a]
00101816
add
eax,1
00101819
mov
dword ptr [a],eax
0010181C
mov
ecx,dword ptr [a]
0010181F
add
ecx,1
00101822
mov
dword ptr [a],ecx
00101825
mov
esi,esp
00101827
mov
edx,dword ptr [__imp_std::endl (1082A8h)]
0010182D
push
edx
0010182E
mov
eax,dword ptr [a]
00101831
add
eax,dword ptr [a]
00101834
mov
edi,esp
00101836
push
eax
00101837
mov
ecx,dword ptr [__imp_std::cout (1082A4h)]
0010183D
call
dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (1082A0h)]
用反汇编来说话
cout<<a+ ++a<<endl;// ==》a++; cout<<a+a;所以22
cout<<++a+ ++a<<endl // ==>a++;a++;cout<< a+a