反汇编之C++的指针与引用

          示例

  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int temp = 100;
  7. int *point = &temp;
  8. int &t = temp;
  9. getch();
  10. }

    反汇编的结果

  11. int temp = 10;
  12. 012718E8 mov dword ptr [temp],0Ah
  13. int *point = &temp;
  14. 012718EF lea eax,[temp] ;将temp变量的地址赋给eax
  15. 012718F2 mov dword ptr [point],eax ;将eax的值赋给point指针
  16. int &t = temp;
  17. 012718F5 lea eax,[temp] ;将temp变量的地址赋给eax
  18. 012718F8 mov dword ptr [t],eax ;将eax的值赋给t引用

    通过反汇编结果可以知道.引用的底层实现就是指针常量.

  19. 转自https://www.cnblogs.com/zengyiwen

猜你喜欢

转载自blog.csdn.net/Gaodes/article/details/81701692