fork download
  1. #include <map>
  2. #include <string>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. void printMap(map<string, int> const& m)
  8. {
  9. for(auto const& p : m)
  10. cout << p.first << " -> " << p.second << endl;
  11. }
  12.  
  13. int main()
  14. {
  15. map<string, int> m;
  16.  
  17. m["Ding"] = 0;
  18. m["Dong"] = 1;
  19. m["Value"] = 284;
  20.  
  21. printMap(m);
  22.  
  23. m["Ding"] = 10;
  24.  
  25. printMap(m);
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
Ding -> 0
Dong -> 1
Value -> 284
Ding -> 10
Dong -> 1
Value -> 284