所以最近我重新访问了有关类型声明的引用,但我不太理解它们。
考虑以下伪代码:
int ia = 10;
int& ref = ia;
现在,我的问题是:
- how do these
int& ref
work internally, does it mean here that the address ofref
is assigned the address ofia
and thus equal to&ia
if not then what does the compiler do upon seeing these references? - Why aren't these references compiled in a c++ program?
提前致谢。
You don't have to think of addresses at all.
ref
is just another name foria
, or put another way,ref
is an alias toia
. Just syntactic sugar for your code.