Hi there, is there posibble in c++ an array or a struct like this php array? $array = array("foo" => "1");
I want to create something like this - something['john'] = 3 and then i want to acces / modify that value only for that name(john), how can i do this?
With STL maps! Here are a few lines of code to show them off:
1 2 3 4 5 6 7
#include <map> //Needed to use the std::map class.
std::map<key_type, value_type> name; //Create a map.
name[key] = value; //The [] operator probably works as it does in PHP.
name.size(); //Get the number of key/value pairs in your map.
name.erase(key); //Guess. :)
name.count(key); //Returns 1 if it found your key, returns 0 otherwise.
name.clear(); //Clears all the key/value pairs.