C2440 “初始化”: 无法从“std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>”转换为“std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>”

错误原因vs已经提醒的很清楚了:无法将const_iterator转换为iterator

我的出错代码是这样的

 

 思考了很久,最后发现原来是因为将函数定义为const的缘故。

总结:当将函数定义为const后,编译器对代码的编译要求立马就搞了起来

原文地址:https://www.cnblogs.com/XiaoXiaoShuai-/p/11625447.html