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
精彩评论