[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