本文介绍了C++中的引用是如何编码的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
int x = 10;
int& y = x;
为此,x
被分配为堆栈上的 2/4/8 个字节,并且 00...1010 被写入这些字节.y
的内存布局及其内容是什么样的?
For this, x
is allocated as 2/4/8 bytes on the stack and 00...1010 is written to those bytes. What would the memory layout and its contents look like for y
?
推荐答案
来自 C++11 标准 8.3.2.4 [dcl.ref]
From the C++11 standard 8.3.2.4 [dcl.ref]
未指定引用是否需要存储
因此它可能需要也可能不需要任何存储.
So it may or may not need any storage.
这篇关于C++中的引用是如何编码的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!