Re: [問題] 關於 lecture#4 的更正
原則上都是一樣的意思... 不過...
※ 引述《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));
應該要寫成 "scores.insert(pair<string, int>("John", 100));"
: 或是
: map<string, int> scores;
: pair<map<string, int>::iterator, bool> p
: = scores.insert(map<string, int>::value_type(“John”, 100));
"value_type" 是被 typedef 成 "pair<string, int>",
不過我個人比較不喜歡用 "value_type", sounds strange to me...
: 不知道上面幾種寫法有什麼不一樣呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.121.133.66
→
11/18 13:35, , 1F
11/18 13:35, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 5 篇):