#include<map>
#include<string>
#include<iostream>
using namespace std;
int main()
{
map<string,int>
m;
m["a"]=1;
m["b"]=2;
m["c"]=3;
map<string,int>::iterator it;
for(it=m.begin();it!=m.end();++it)
cout<<"key: "<<it->first <<" value: "<<it->second<<endl;
return
0;
}
#include<string>
#include<iostream>
using namespace std;
int main()
{
}
map<string,int>::iterator it;
定义一个迭代指针it。
it->first 为索引键值,it->second 为值。
最后
以上就是酷酷航空最近收集整理的关于C++ Map的遍历的全部内容,更多相关C++内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复