精華區beta EE_DSnP 關於我們 聯絡資訊
原則上都是一樣的意思... 不過... ※ 引述《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
ric2k1:"make_pair" 是 function, pair<..>(...) 是 constructor 11/18 13:35