C++映射迭代器
示例
容器中第一个元素的迭代器。
如果映射对象是const限定符,则该函数返回const_iterator。否则,返回iterator。
//创建映射并插入一些值
std::map<char,int> mymap;
mymap['b'] = 100;
mymap['a'] = 200;
mymap['c'] = 300;
//遍历所有元组
for (std::map<char,int>::iterator it = mymap.begin(); it != mymap.end(); ++it)
std::cout << it->first << " => " << it->second << '\n';输出:
a=>200
b=>100
c=>300