作者ric2k1 (Ric)
看板EE_DSnP
标题[公告] Lecture note #4 更正
时间Fri Nov 17 19:23:31 2006
[Slide #34]
-----------
map<string, int> scores;
pair<map<string, int>::iterator, bool> p
= scores.insert(
"John");
应更正为 ---
map<string, int> scores;
pair<map<string, int>::iterator, bool> p
= scores.insert(
make_pair("John", 100));
原因 ---
map 的 "insert()" 不能只传 "KEY", 要传 "KEY" and "VALUE" 的 pair.
==============
另外, 有人问到 slide #17... 投影片是没有错的, 只是我上课好像将 'a' 说成 int
type 了, 应为 "int*".
==============
还有, 关於 vector 的 resize --> 是不一定会长大 allocate memory...
It depends the original "capacity" and the target "resize n"...
If the "resize n" is smaller or equal to the "capacity", of course there is
no need to re-allocate the memory...
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.21.240