Re: [問題] reference 問題

看板C_and_CPP (C/C++)作者 (石斛蘭)時間16年前 (2009/09/16 01:27), 編輯推噓2(202)
留言4則, 2人參與, 最新討論串2/5 (看更多)
: 再請問一下,下面的是錯在哪呢? : (1) const string& ref2 = string("hala"); : (2) const vector<int>& ref = vector<int>(); 剛剛看到的 (12.2.5) The temporary to which the reference is bound or the temporary that is the complete object of a subobject to which the reference is bound persists for the lifetime of the reference except as specified below. ...略 In all these cases, the temporaries created during the evaluation of the expression initializing the reference, except the temporary to which the reference is bound, are destroyed at the end of the full -expression in which they are created and in the reverse order of the completion of their construction. -- 貓 http://www.onlypet.com.tw/dendrobium -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.31.128.208

09/16 02:49, , 1F
請教英文了 他這邊一直提到的bound 是啥意思??
09/16 02:49, 1F

09/16 02:51, , 2F
而且其實有點不了解他在講什麼...有強者大大解事一下嘛?
09/16 02:51, 2F

09/16 04:02, , 3F
剛剛查了一下 這篇講得還蠻清楚的 http://0rz.tw/vFZOS
09/16 04:02, 3F

09/16 04:02, , 4F
差點忘記還有RVO這個東西 也是這樣弄的~
09/16 04:02, 4F
文章代碼(AID): #1AhywCGR (C_and_CPP)
討論串 (同標題文章)
文章代碼(AID): #1AhywCGR (C_and_CPP)