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.
引用是其所指
这篇关于有没有办法找到引用的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有没有办法找到引用的地址?
基础教程推荐
- 初始化列表*参数*评估顺序 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- CString 到 char* 2021-01-01
