有没有办法找到引用的地址?

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.

引用是其所指

这篇关于有没有办法找到引用的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:有没有办法找到引用的地址?

基础教程推荐