|
|
@ -4,11 +4,13 @@
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
#include <utility>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using std::map;
|
|
|
|
|
|
|
|
using std::pair;
|
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
int main() {
|
|
|
|
// notice how the lists are nested to match the templates' parameters:
|
|
|
|
// notice how the lists are nested to match the templates' parameters:
|
|
|
|
map<string, vector<pair<string, int>>> name_languages_year {
|
|
|
|
map<std::string, vector<pair<std::string, int>>> name_languages_year {
|
|
|
|
{"Dennis Ritchie", {{"B", 1969}, {"C", 1973}}},
|
|
|
|
{"Dennis Ritchie", {{"B", 1969}, {"C", 1973}}},
|
|
|
|
{"Niklaus Wirth", {{"Pascal", 1970}, {"Modula-2", 1973},
|
|
|
|
{"Niklaus Wirth", {{"Pascal", 1970}, {"Modula-2", 1973},
|
|
|
|
{"Oberon", 1986}}},
|
|
|
|
{"Oberon", 1986}}},
|
|
|
@ -17,7 +19,7 @@ int main() {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// prints `Pascal':
|
|
|
|
// prints `Pascal':
|
|
|
|
cout << name_languages_year["Niklaus Wirth"].at(0).first << endl;
|
|
|
|
std::cout << name_languages_year["Niklaus Wirth"].at(0).first << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
// adds a new entry to the map:
|
|
|
|
// adds a new entry to the map:
|
|
|
|
name_languages_year["John McCarthy"] = {
|
|
|
|
name_languages_year["John McCarthy"] = {
|
|
|
@ -25,5 +27,5 @@ int main() {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// prints 'Lisp':
|
|
|
|
// prints 'Lisp':
|
|
|
|
cout << name_languages_year["John McCarthy"].at(0).first << endl;
|
|
|
|
std::cout << name_languages_year["John McCarthy"].at(0).first << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|