C++中的引用与指针 汇编代码

int main(int argc, char ** argv)
{
。。。。。。。。
int x = 3;
003913DE mov dword ptr [x],3
int &y = x;
003913E5 lea eax,[x]
003913E8 mov dword ptr [y],eax
int *z = &x;
003913EB lea eax,[x]
003913EE mov dword ptr [z],eax

*z = 4;

003913F1 mov eax,dword ptr [z]
003913F4 mov dword ptr [eax],4

y = 5;
003913FA mov eax,dword ptr [y]
003913FD mov dword ptr [eax],5

x = 6;
00391403 mov dword ptr [x],6

cout<<x<<endl;
0039140A mov esi,esp
0039140C mov eax,dword ptr [__imp_std::endl (398298h)]
00391411 push eax
00391412 mov edi,esp
00391414 mov ecx,dword ptr [x]
00391417 push ecx
00391418 mov ecx,dword ptr [__imp_std::cout (398290h)]
0039141E call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (398294h)]
00391424 cmp edi,esp
00391426 call @ILT+325(__RTC_CheckEsp) (39114Ah)
0039142B mov ecx,eax
0039142D call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (39829Ch)]
00391433 cmp esi,esp
00391435 call @ILT+325(__RTC_CheckEsp) (39114Ah)
return 0;
0039143A xor eax,eax
}

。。。。。。。。。

C++中,引用的本质就是指针

  引用是编译器对指针的封装

  引用由编译器寻址,指针由程序员寻址

  反汇编代码中没有引用的概念

 

posted @ 2015-03-04 15:42  田田超人  阅读(264)  评论(0编辑  收藏  举报