Question

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)

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top