fork download
  1. #include <vector>
  2. #include <iostream>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. class Test
  8. {
  9. public:
  10. Test(int i):i(i){}
  11. void out() const { cout << "Test for " << i << endl; }
  12. private:
  13. int i;
  14. };
  15.  
  16. int main(int argc, const char * argv[])
  17. {
  18. vector<Test> s;
  19. for(int i = 0; i < 10; ++i)
  20. s.push_back(Test(rand()%100));
  21.  
  22. for(auto it = s.begin(); it != s.end(); ++it)
  23. it->out();
  24.  
  25. }
  26.  
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Test for 83
Test for 86
Test for 77
Test for 15
Test for 93
Test for 35
Test for 86
Test for 92
Test for 49
Test for 21