Does C++ have a dictionary similar to Objective-C's NSDictionary?
c++, cocoa, dictionary, nsdictionary, objective-c
Solution
Use std::map.
For example, to map from integers to std::string:
#include <map>
#include <string>
#include <iostream>
int main() {
std::map<int, std::string> my_map;
my_map[3] = "hello";
my_map[4] = "world";
std::cout << my_map[3] << " " << my_map[4] << std::endl;
return 0;
}
Problem
As the title says, is there a dictionary similar to Objective-C's `NSDictionary` for C++? I just need a data structure that holds a (key,value) pair and can be added and retrieved.