加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C:参考地址?

发布时间:2020-12-16 10:28:45 所属栏目:百科 来源:网络整理
导读:我对C arcana的了解有点粗糙.假设我有以下课程: struct Bar { int x;};class Foo { Bar bar;public: Bar* getRealAddress() { return bar; } Foo(Bar _bar) : bar(_bar) {}};Bar bar1;Foo foo1(bar1); foo1.getRealAddress()会返回与 bar1相同的值吗? 解决
我对C arcana的了解有点粗糙.假设我有以下课程:

struct Bar {
  int x;
};

class Foo {
  Bar& bar;
public:
  Bar* getRealAddress() { return &bar; }
  Foo(Bar& _bar) : bar(_bar) {}
};

Bar bar1;
Foo foo1(bar1);

foo1.getRealAddress()会返回与& bar1相同的值吗?

解决方法

Will foo1.getRealAddress() return the same value as &bar1?

是.

基本上,引用是除名称之外的所有值的原始值.这是别名.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读