Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- map<string, pair<string,string> > myMap;
- myMap.insert(make_pair(first_name, make_pair(middle_name, last_name)));
- for(map<string, pair<string,string> >::const_iterator it = myMap.begin();
- it != myMap.end(); ++it)
- {
- std::cout << it->first << " " << it->second.first << " " << it->second.second << "n";
- }
- for(auto it = myMap.cbegin(); it != myMap.cend(); ++it)
- {
- std::cout << it->first << " " << it->second.first << " " << it->second.second << "n";
- }
- for(auto elem : myMap)
- {
- std::cout << elem.first << " " << elem.second.first << " " << elem.second.second << "n";
- }
- for (auto& t : myMap)
- std::cout << t.first << " "
- << t.second.first << " "
- << t.second.second << "n";
- typedef std::pair<string, std::pair<string, string> > T;
- std::ostream &operator<<(std::ostream &os, T const &t) {
- return os << t.first << " " << t.second.first << " " << t.second.second;
- }
- // ...
- std:copy(myMap.begin(), myMap.end(), std::ostream_iterator<T>(std::cout, "n"));
- std::map<std::string, std::pair<std::string, std::string>> myMap;
- myMap["x"] = { "a", "b" };
- myMap["y"] = { "c", "d" };
- for (auto &[k, v] : myMap)
- std::cout << "m[" << k << "] = (" << v.first << ", " << v.second << ") " << std::endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement