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

后端 未结 6 1362
自闭症患者
自闭症患者 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 13:01

    You can also do like this-

     std::map::iterator it = m.find('c'); 
     if (it != m.end())
     (*it).second = 42;
    

提交回复
热议问题