开发者

Index strings by other strings

I need to index specific strings with other strings and I can't really find a good way to do so. I tried to use tr1开发者_运维技巧::unordered_map, but I'm having some difficulties using it. If someone could tell me what is the best way to do that I'd be really grateful :) I also need to index objects by a number (numbers are not in order so I can't use a vector)


What about std::map?

std::map<std::string, std::string> foo;

Then you can add elements,

foo["bar"] = "baz";
cout << foo["bar"] << std::endl;  // baz
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜