问题描述
map<string, int>::key_type v1;//v1 stringmap<string, int>::value_type v2;//v2 pair<const string,int>
为何后者的key_type 是const?而 mapped_type 又不是const?
问题解答
回答1:因为你没办法对一个已经添加进Map当中的K/V对的键进行更改,只能对值进行更改。如果要对键进行更改,只能删掉这个,然后再添加一个新的。

问题描述
map<string, int>::key_type v1;//v1 stringmap<string, int>::value_type v2;//v2 pair<const string,int>
为何后者的key_type 是const?而 mapped_type 又不是const?
问题解答
回答1:因为你没办法对一个已经添加进Map当中的K/V对的键进行更改,只能对值进行更改。如果要对键进行更改,只能删掉这个,然后再添加一个新的。
相关文章:1. solaris基础和常用知识 (2)2. 为什么矛那里的 <a href=" " 这地方为什么是空的呢 ??3. 为什么总是提示我说Template "movieTemplate" not found,我路径都引对了呀4. <tr valign="top"> 看不懂5. mysql - sphinx查询 "中国" 时也能查询到 "中华人民共和国"6. MySQL"="自动 like7. node.js mysql Cannot find module "net" 和 "tls"和"fs" 的问题8. mysql 使用 join 还是 "," 进行多表查询???9. mysql - 使用hibernate连接数据库时,数据库版本过高不支持关键字"type" ;10. 发现 <li><a href="/index.php">回到前台</a></li>这样回到首页后,不是登录状态

网公网安备:皖ICP备2020019022号-8 Copyright ¢ 2020-2025 Powered by V1.8 All Rights Reserved 技术支持:乐呵呵网
声明:本站所有资源以学习为主