Re: [問題] 關於 lecture#4 的更正

看板EE_DSnP作者 (Ric)時間17年前 (2006/11/18 13:13), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串2/5 (看更多)
原則上都是一樣的意思... 不過... ※ 引述《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
"make_pair" 是 function, pair<..>(...) 是 constructor
11/18 13:35, 1F
文章代碼(AID): #15NfQ9X9 (EE_DSnP)
討論串 (同標題文章)
文章代碼(AID): #15NfQ9X9 (EE_DSnP)