|
|
std::map<std::string, std::string> x = {{"A", "ASDF"}, {"B", "DESU"}, {"C", "BLAH"}};
That's called std::map (or std::multimap if multiple keys are allowed, or std::unordered_map if you want a hash table, etc. You really should look at a reference or a textbook, I think) std::map<std::string, std::string> x = {{"A", "ASDF"}, {"B", "DESU"}, {"C", "BLAH"}}; online demo: http://ideone.com/J8eeIb (for older compilers, same caveat as with vectors: either add them one by one, x["A"] = "ASDF"; etc, or build from an array of pairs) |