关联容器迭代器的一个例子
发布日期:2021-05-07 00:57:09 浏览次数:21 分类:精选文章

本文共 424 字,大约阅读时间需要 1 分钟。

#include 
#include
#include
#include
using namespace std;int main(){map
word_count ={ {"str1",1},{"str2",2},{"str3",3},{"str4",4},{"str5",5}};map
::iterator map_it = word_count.begin();++ map_it->second;cout << map_it->first <
<< map_it->second << endl; return 0;}

必须记住,一个map的value_type是一个pair,我们可以改变pair的值(也就是mapped_type类型的那个成员),但是不能改变关键字成员的值。

上一篇:关联容器使用copy算法,把元素从一个关联容器拷贝到另一个容器
下一篇:c++ primer5th 习题11.14自编答案

发表评论

最新留言

不错!
[***.144.177.141]2025年04月16日 04时25分32秒