fork download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4.  
  5. struct Data
  6. {
  7. Data(const std::string& name, int x):
  8. m_Name(name),
  9. m_X(x)
  10. {}
  11.  
  12. std::string m_Name;
  13. int m_X;
  14. };
  15.  
  16. std::vector<Data> datas =
  17. {
  18. Data("one", 1),
  19. Data("two", 2),
  20. Data("three", 3),
  21. };
  22.  
  23. int main()
  24. {
  25. for(auto it = datas.begin(); it != datas.end(); ++it)
  26. std::cout << it->m_Name << " " << it->m_X << "\n";
  27.  
  28. }
Success #stdin #stdout 0s 3032KB
stdin
Standard input is empty
stdout
one 1
two 2
three 3