Possible Duplicate:
typedef and containers of const pointers誤差在臨時附着到參考爲const
爲什麼代碼發射錯誤?
int main()
{
//test code
typedef int& Ref_to_int;
const Ref_to_int ref = 10;
}
的錯誤是:
error: invalid initialization of non-const reference of type ‘int&’ from a temporary of type ‘int’
我讀prolonging the lifetime of temporaries後它說,臨時對象可以綁定到const的引用。那爲什麼我的代碼沒有被編譯?
什麼是錯誤? – 2011-05-20 11:30:45