Comparison of programming languages (associative array): Difference between revisions

Content deleted Content added
Line 95:
phone_book["John Doe"] = "555-1212";
phone_book["J. Random Hacker"] = "553-1337";
}
return 0;
</source>
 
With the extension of [[C++11#Initializer_lists|initialization lists]] in C++11, entries can be added during a map's construction as shown below:
 
<source lang=Cpp>
#include <map>
#include <string>
 
int main() {
std::map<std::string, std::string> phone_book {
{"Sally Smart", "555-9999"},
{"John Doe", "555-1212"},
{"J. Random Hacker", "553-1337"}
};
}
</source>