参考如何在内部实现? [英] How are references implemented internally?

查看:73
本文介绍了参考如何在内部实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道如何在不同的编译器和调试/发布配置中实际实现引用.该标准是否提供有关其实施的建议?实现有区别吗?

I'm just wondering how references are actually implemented across different compilers and debug/release configurations. Does the standard provide recommendations on their implementation? Do implementations differ?

我试图运行一个简单的程序,在该程序中我从函数返回非常量引用和指向局部变量的指针,但是它们的工作方式相同.这是否意味着引用在内部只是一个指针?

I tried to run a simple program where I return non-const references and pointers to local variables from functions, but they worked out the same way. Does this mean that references are internally just a pointer?

推荐答案

引用的自然实现确实是一个指针.但是,请不要在您的代码中依赖它.

The natural implementation of a reference is indeed a pointer. However, do not depend on this in your code.

这篇关于参考如何在内部实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆