fork(1) download
  1. #include <utility>
  2. #include <iostream>
  3. #include <vector>
  4. #include <string>
  5.  
  6. typedef std::pair<int, std::string> pairIntString;
  7. int main()
  8. {
  9. std::vector<pairIntString> pairVec;
  10.  
  11. pairVec.push_back(std::make_pair(1, "One"));
  12. pairVec.push_back(std::make_pair(2, "Two"));
  13. pairVec.push_back(std::make_pair(3, "Three"));
  14.  
  15. for (std::vector<pairIntString>::const_iterator iter = pairVec.begin();
  16. iter != pairVec.end();
  17. ++iter)
  18. {
  19. std::cout << "First: " << iter->first << ", Second: " << iter->second <<std::endl;
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
First: 1, Second: One
First: 2, Second: Two
First: 3, Second: Three