-3
)
我正在使用迭代器编写C++程序。我有一个数据结构是一张地图。我使用迭代器从地图的开始到结束进行循环,对于地图的每个元素,我都使用键和值进行操作。C++:无法找到(STL的)对库(
因此,当我想知道关键字和地图特定元素的值时,我在我的迭代器上使用first()和second()。
像这样:
#include <map>
#include <pair>
map<unsigned long, int> myMap;
map<unsigned long, int>::const_iterator it;
for(it = myMap.cbegin(); it != myMap.cend(); ++it)
{
unsigned long key_of_map = it.first();
int val = it.second();
cout << "Key is : " << key_of_map << endl << "Value is : " << val << endl;
}
当我编译它,它告诉我:
“../src/myfile.cpp:16:10:致命错误: '对' 文件不发现“
我使用Eclipse(版本月神),标准版我从官方网站上下载(我没有改变任何东西)。
感谢您的帮助!
''