char* a = "aaa";
map<char*, int> m;
m.insert(pair<char*, int>(a,5));
a[0] = 'c';
a[1] = 'c';
a[2] = 'c';
cout << a << endl; // a = `ccc`
cout << m["aaa"] << endl; // found the node by `aaa`,
cout << m.begin()->first << endl; // but the node's left is actually `ccc`?
有趣的問題,所以該節點的左邊是ccc
或aaa
?地圖<char*, int>
問題很不清楚。 – Nawaz
@Nawaz有問題嗎? –
您試圖修改只讀字符串文字。結果將是未定義的行爲。 –