iterator const_iterator

来源:互联网 发布:网络咨询医生工资待遇 编辑:程序博客网 时间:2024/05/16 20:27

今日写程序,使用了const 类型的 map 作为形参传给函数,函数中访问map元素时发生错误。

1,const类型的容器不能或者最好不要使用下标访问。非const可以,否则预报段错误。

2,const类型的容器只能使用const_iterator,不能使用iterator。


0 0