作者ric2k1 (Ric)
看板EE_DSnP
标题Re: [问题] 关於 lecture#4 的更正
时间Sat Nov 18 13:16:49 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));
应该要写成 "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
1F:→ ric2k1:"make_pair" 是 function, pair<..>(...) 是 constructor 11/18 13:35