How to update std::map after using the find method?

后端 未结 6 1356
自闭症患者
自闭症患者 2020-12-12 12:11

How to update the value of a key in std::map after using the find method?

I have a map and iterator declaration like this:

         


        
6条回答
  •  情话喂你
    2020-12-12 12:56

    You can update the value like following

       auto itr = m.find('ch'); 
         if (itr != m.end()){
               (*itr).second = 98;
         }
    

提交回复
热议问题