当前位置: 代码迷 >> 综合 >> iterator const_iterator
  详细解决方案

iterator const_iterator

热度:52   发布时间:2024-01-16 08:24:08.0

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

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

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


  相关解决方案