Re: [問題] reference 問題
: 再請問一下,下面的是錯在哪呢?
: (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
09/16 02:49, 1F
→
09/16 02:51, , 2F
09/16 02:51, 2F
推
09/16 04:02, , 3F
09/16 04:02, 3F
→
09/16 04:02, , 4F
09/16 04:02, 4F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章