示例
#include<iostream>using namespace std;int main(){int temp = 100;int *point = &temp;int &t = temp;getch();}反汇编的结果
int temp = 10;012718E8 mov dword ptr [temp],0Ahint *point = &temp;012718EF lea eax,[temp] ;将temp变量的地址赋给eax012718F2 mov dword ptr [point],eax ;将eax的值赋给point指针int &t = temp;012718F5 lea eax,[temp] ;将temp变量的地址赋给eax012718F8 mov dword ptr [t],eax ;将eax的值赋给t引用通过反汇编结果可以知道.引用的底层实现就是指针常量.
本文通过C++代码示例及反汇编结果详细解释了引用与指针的底层实现方式,揭示了引用实际上是以常量指针的形式存在的,并通过具体的汇编指令展示这一过程。
1521

被折叠的 条评论
为什么被折叠?



