Is there any way to find the address of a reference?(有没有办法找到引用的地址?)
问题描述
有没有办法找到引用的地址?
Is there any way to find the address of a reference?
使其更具体:变量本身的地址,而不是初始化它的变量的地址.
Making it more specific: The address of the variable itself and not the address of the variable it is initialized with.
推荐答案
参考文献没有自己的地址.虽然引用可以实现为指针,但没有必要或保证这一点.
References don't have their own addresses. Although references may be implemented as pointers, there is no need or guarantee of this.
C++ FAQ 说得最好:
与指针不同,一旦引用被绑定到一个对象,它不能重置"到另一个对象.这引用本身不是一个对象(它没有身份;取地址一个参考给你的地址指称者;记住:参考是它的参照物).
Unlike a pointer, once a reference is bound to an object, it can not be "reseated" to another object. The reference itself isn't an object (it has no identity; taking the address of a reference gives you the address of the referent; remember: the reference is its referent).
另请在此处查看我的回答以获取综合列表引用与指针有何不同.
Please also see my answer here for a comprehensive list of how references differ from pointers.
引用是其所指
这篇关于有没有办法找到引用的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有没有办法找到引用的地址?


基础教程推荐
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 常量变量在标题中不起作用 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01