fork download
  1. #include <map>
  2. #include <utility>
  3. #include <tuple>
  4. #include <iostream>
  5. #include <string>
  6.  
  7. typedef std::map< std::tuple<std::string, std::string, int, int>, int> Table;
  8.  
  9. int main()
  10. {
  11. Table my_table;
  12. std::string a = "Kode", b = "Warrior";
  13. int c = 3, d = 4, e = 5;
  14.  
  15. // 1. Support insert operations for each row.
  16. my_table.insert(std::make_pair(std::make_tuple(a, b, c, d), e));
  17.  
  18. // 2. Given the values for Col1, Col2, Col3, Col4 find the value of Col5
  19. auto it = my_table.find(std::make_tuple(a, b, c, d));
  20. std::cout << it->second; // prints e
  21.  
  22. // 3. Given Col1, Col2, COl3, Col4 update Col5
  23. it->second = 6; // assign some other value
  24. }
Success #stdin #stdout 0s 2988KB
stdin
Standard input is empty
stdout
5