作者EEmuse2 (忘了密碼)
看板EE_DSnP
標題Re: [問題] 關於 lecture#4 的更正
時間Sat Nov 18 17:35:12 2006
※ 引述《samuelduan ()》之銘言:
: map<string, int> scores;
: pair<map<string, int>::iterator, bool> p
: = scores.insert(make_pair(“John”, 100));
: 上面的是更正的版本
: 而我之前查了一些資料
: 有人寫成
: map<string, int> scores;
: pair<map<string, int>::iterator, bool> p
: = scores.insert(pair(“John”, 100));
: 或是
: map<string, int> scores;
: pair<map<string, int>::iterator, bool> p
: = scores.insert(map<string, int>::value_type(“John”, 100));
: 不知道上面幾種寫法有什麼不一樣呢?
: map<string, int> scores;
: pair<map<string, int>::iterator, bool> p
: = scores.insert(make_pair(“John”, 100));
想在請問這句語法insert return的值是給first還是second , 或者說為何可以這樣
assign??
謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.4.247
推 ric2k1:return 一個 pair 的物件給 p 11/18 18:55
→ ric2k1:然後你可以用 p.first, p.second... 11/18 18:56