fork download
  1. #include <sstream>
  2. #include <iostream>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. struct Item
  7. {
  8. std::string word = "";
  9. std::vector<int> count = {0, 0, 0};
  10. };
  11. using Pair = std::pair<int, std::vector< std::pair<int, Item> > >;
  12.  
  13. int main()
  14. {
  15. std::vector< Pair > MyWords =
  16. { //int, <std::pair<int, Item > > >
  17. {1 , { { 4, Item{"String1", {1,2,3}} } } },
  18. {0 , { { 5, Item{"String2", {5,2,8}} } } },
  19. {2 , { { 8, Item{"String3", {1,7,9}} } } }
  20. };
  21.  
  22. int key1 = 0;
  23. int key2 = 0;
  24. std::cout << MyWords[key1].second[key2].second.count[0] << std::endl;
  25. MyWords[0].second[key1].second.count[key2] = 7;
  26. std::cout << MyWords[key1].second[key2].second.count[0] << std::endl;
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 4540KB
stdin
Standard input is empty
stdout
1
7