PHP and Javascript are not strongly typed, in C ++ you would like to create a structure that describes your user, and not rely on arbitrary strings as keys:
struct User { size_t _age; std::string _city; std::string _country; };
Then you can create an index to link to these users by name (you can also save the specified name with the user). The two containers for this are std::map and std::unordered_map , in the general case.
std::map<std::string, User> users; User& user = users["CIRK"]; user._age = 20; user._country = "USA"; user._city = "New York";
Note that I cached the search in the array by creating a link (and that the object is automatically created if it is not already present).
Matthieu M.
source share