我想知道为什么我的输出看起来像这样:
This : 1
a : 4
is : 2
just : 3
test : 5
Run Code Online (Sandbox Code Playgroud)
当我的代码看起来像这样:
map<string, int> wordCount;
wordCount["This"] = 1;
wordCount["is"] = 2;
wordCount["just"] = 3;
wordCount["a"] = 4;
wordCount["test"] = 5;
for (map<string, int>::iterator it = wordCount.begin();
it != wordCount.end(); it++) {
cout << it->first << " : " << it->second << endl;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,地图以随机顺序存储对象吗?