#include <iostream>
#include <string.h>
#include <vector>
#include <map>
class mapTest
{
public:
void appenData()
{
_mapData.insert({ 0,"0" });
_mapData.insert({ 0,"1" });
_mapData.insert({ 0,"2" });
int a = 0;// _mapData value: 0 "0" 更改无效 //第二次insert失效
}
void appendData2()
{
_mapData[0] = "0";
_mapData[0] = "1";
_mapData[0] = "2";
int a = 0;// _mapData value: 0 "2" 更改成功
}
protected:
private:
std::map<int, std::string> _mapData;
};
int main()
{
mapTest tt;
tt.appenData();
tt.appendData2();
}