int x = 10;
int& y = x;
为此,x
在堆栈上分配为 2/4/8 个字节,并将 00...1010 写入这些字节。 y
的内存布局及其内容是什么样的?
最佳答案
来自 C++11 标准 8.3.2.4 [dcl.ref]
It is unspecified whether or not a reference requires storage
所以它可能需要也可能不需要任何存储空间。
关于c++ - C++ 中的引用是如何编码的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31521116/