《map的两种插入方法》由会员分享,可在线阅读,更多相关《map的两种插入方法(1页珍藏版)》请在金锄头文库上搜索。
map的两种插入方法mymap.insert()这种赋值不会覆盖原来的值而=这种赋值会覆盖掉原来的值写入新值代码如下#include#includeusingnamespacestd;intmain()mapmymap;mymap5=3;mymap5=4;mapmap,intMYMAP;coutmymap5endl;mymap.insert(pair(5,3);mymap.insert(pair(5,10);coutmymap5endl;输出俩4证明mymap.insert()这种赋值不会覆盖原来的值而=这种赋值会覆盖掉原来的值写入新值system(pause);return0;