SHARE
TWEET

Untitled

a guest Mar 21st, 2019 39 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. map<string, pair<string,string> > myMap;
  2.      
  3. myMap.insert(make_pair(first_name, make_pair(middle_name, last_name)));
  4.      
  5. for(map<string, pair<string,string> >::const_iterator it = myMap.begin();
  6.     it != myMap.end(); ++it)
  7. {
  8.     std::cout << it->first << " " << it->second.first << " " << it->second.second << "n";
  9. }
  10.      
  11. for(auto it = myMap.cbegin(); it != myMap.cend(); ++it)
  12. {
  13.     std::cout << it->first << " " << it->second.first << " " << it->second.second << "n";
  14. }
  15.      
  16. for(auto elem : myMap)
  17. {
  18.    std::cout << elem.first << " " << elem.second.first << " " << elem.second.second << "n";
  19. }
  20.      
  21. for (auto& t : myMap)
  22.     std::cout << t.first << " "
  23.               << t.second.first << " "
  24.               << t.second.second << "n";
  25.      
  26. typedef std::pair<string, std::pair<string, string> > T;
  27.  
  28. std::ostream &operator<<(std::ostream &os, T const &t) {
  29.     return os << t.first << " " << t.second.first << " " << t.second.second;
  30. }
  31.  
  32. // ...
  33. std:copy(myMap.begin(), myMap.end(), std::ostream_iterator<T>(std::cout, "n"));
  34.      
  35. std::map<std::string, std::pair<std::string, std::string>> myMap;
  36. myMap["x"] = { "a", "b" };
  37. myMap["y"] = { "c", "d" };
  38.  
  39. for (auto &[k, v] : myMap)
  40.     std::cout << "m[" << k << "] = (" << v.first << ", " << v.second << ") " << std::endl;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top