喜 我在看一個C++教程和 教練包括這樣問題調用庫
# include "map.h"
#include "set.h"
但是當我使用此代碼我收到錯誤
致命錯誤C1083庫:無法打開包括 文件:'set.h':沒有這樣的文件或 目錄
,所以我必須把它寫這樣
# include <map>
#include <set>
,但現在我還有一個問題 當我創建一個組或地圖OB,我可以使用的方法是從什麼教程 例如顯示不同在本教程教師創建和瀏覽一組或映射這樣
set<int> ss;
set<int>::itrator itr = ss.itrator();
while(itr.hasnext()){
cout<<itr.next();
}
,但我的SS和對象不具有此方法
ss.itrator();
itr.hasnext()
itr.next();
我必須這樣寫這樣的代碼
set<int> ss;
set<int>::itrator itr = ss.begin();
while(!itr.end()){
cout<<*itr;
}
是什麼問題?
Nitpick:'for(std :: ::'** const _ **'iterator itr = ss.begin(),'** end = ss.end()**'; itr!= end;'** ++ **'ITR)'。 –
2011-04-30 18:09:00
@mmutz爲了簡單起見,我自願離開'const'迭代器。剩下的,我承認我從來沒有在'for'循環的前提下做過類似'end = ss.end()'的事情('collection.end()'從來沒有出現在我的任何程序的分析報告中)。 – zneak 2011-04-30 18:12:40
[nitpick(1)](http://en.wiktionary.org/wiki/nitpick):)關於'end = ss.end()':它被稱爲「避免過早悲觀」。 – 2011-04-30 18:16:59