作者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
1F:推 ric2k1:return 一个 pair 的物件给 p 11/18 18:55
2F:→ ric2k1:然後你可以用 p.first, p.second... 11/18 18:56