上課時講到的例子:
int a = 10;
int *p = &a;
const int *& q = p;
....
....
事實上 compile 不會過!!
因為 "int*" 與 "const int*" 不同, 不能當作彼此的 reference.
---
"refernce" 是 compile time 決定的東西.
"reference" type variable 並不會佔用記憶體位置, compiler 在 compile time
就會用 symbol table 把它 resolve 掉了!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.21.241