fork download
  1. #include <iostream>
  2.  
  3. #include <vector>
  4. #include <map>
  5.  
  6. using namespace std;
  7.  
  8. std::vector<std::map<std::string, std::string>> structie;
  9.  
  10. int main() {
  11. // your code goes here
  12. map<string,string> tmpMap;
  13. tmpMap["A"] = "a";
  14. tmpMap["B"] = "b";
  15.  
  16. structie.push_back( tmpMap );
  17. tmpMap.clear();
  18.  
  19. tmpMap["A"] = "one";
  20. //tmpMap["B"] = "two";
  21.  
  22. structie.push_back( tmpMap );
  23.  
  24. for(vector<map<string,string>>::iterator it = structie.begin(); it != structie.end(); ++it) {
  25. cout << it->at("A") << endl;
  26. cout << it->at("B") << endl;
  27. cout << endl;
  28. }
  29.  
  30. return 0;
  31. }
Runtime error #stdin #stdout #stderr 0s 3464KB
stdin
Standard input is empty
stdout
a
b

one
stderr
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at