作者ric2k1 (Ric)
看板EE_DSnP
標題[更正] const int *& q 的問題
時間Wed Mar 12 18:02:05 2008
上課時講到的例子:
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