关于 stl map 的 []操作符问题
来源:互联网 发布:js 构造函数 编辑:程序博客网 时间:2024/06/11 03:18
stl 文档中是如下描述:
Access element
If k matches the key of an element in the container, the function returns a reference to its mapped value.If k does not match the key of any element in the container, the function inserts a new element with that key and returns a reference to its mapped value. Notice that this always increases the container size by one, even if no mapped value is assigned to the element (the element is constructed using its default constructor).
注意斜体字部分,也就是说,如果你的对象想保存在 map 中并且要用到[] 那么你的类起码要实现以下几个函数:无参数的构造函数 --- 对应元素不存在时 map 自行创建。operator = ----- 用于 通过 [] 操作符来赋值拷贝构造函数 ---- 可能要用到,没具体研究,反正实现了总比不实现要好。
阅读全文
0 0
- 关于 stl map 的 []操作符问题
- STL: Map 的操作
- STL中关于map和set的四个问题?
- STL中关于map和set的四个问题
- STL中关于map和set的一些问题
- STL中关于map和set的四个问题?
- STL中关于map和set的四个问题?
- STL Map 的简单操作
- 一个关于STL map定义问题
- 小心使用STL中map的[]操作符
- 使用STL中map的[]操作符方法
- 小心使用STL中map的[]操作符[转]
- 小心使用STL中map的[]操作符
- 小心使用STL中map的[]操作符
- 小心使用STL中map的[]操作符
- 小心使用STL中map的[]操作符
- 小心使用STL中map的[]操作符
- STL中map的erase操作
- zabbix监控第一台主机系统
- Python易错点整理——for和else的搭配使用、global的使用
- Git实例学习
- 复制表
- HDU 1003 (最大子序列和)
- 关于 stl map 的 []操作符问题
- HDUOJ 水果
- 【poj3630】Phone List 【Nordic 2007】
- 网卡驱动程序
- 数据结构树
- POJ3468 A Simple Problem with Integers(线段树区间更新,lazy标记)
- 01QT编写自己的UC浏览器-编写带标题栏和Aero效果的浏览器框架
- 度度熊的午饭时光 百度之星
- Android开发——文本控件——Textview