#include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
map<string, int> map1;
map1[string("tttt")] = 1;
map1[string("ggg")] = 2;
map1.insert(pair<string, int>("niubi", 3));
map<string, int>::iterator it = map1.begin();
while ( it != map1.end())
{
cout<<it->first<<" "<<it->second<<endl;
it++;
}
system("pause");
return 0;
}C++ map容器的2种初始化方法
本文深入探讨了C++编程中利用STL(标准模板库)进行高效数据操作的方法,包括如何使用map容器进行键值对存储与检索,并通过迭代器遍历与打印数据。

被折叠的 条评论
为什么被折叠?



