小编Ton*_*Gin的帖子

c ++对象的地图顺序

我想知道为什么我的输出看起来像这样:

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)

我的问题是,地图以随机顺序存储对象吗?

c++ dictionary stl

2
推荐指数
1
解决办法
61
查看次数

标签 统计

c++ ×1

dictionary ×1

stl ×1