fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <sstream>
  5. using namespace std;
  6.  
  7. class Point
  8. {
  9. int x;
  10. int y;
  11.  
  12. public:
  13. Point(int x = 0, int y = 0) : x(x), y(y)
  14. {
  15.  
  16. }
  17.  
  18. std::string string()
  19. {
  20. std::stringstream ss;
  21.  
  22. ss << x;
  23. ss << ", ";
  24. ss << y;
  25.  
  26. return ss.str();
  27. }
  28. };
  29.  
  30. void print(const std::vector<Point> &points)
  31. {
  32. for (Point p : points)
  33. {
  34. std::cout << p.string() << std::endl;
  35. }
  36. }
  37.  
  38. int main() {
  39. std::vector<Point> points(3);
  40.  
  41. print(points);
  42.  
  43. for (int i = 0; i < points.size(); ++i)
  44. {
  45. points.at(i) = Point(1, 1);
  46. }
  47.  
  48. print(points);
  49.  
  50. return 0;
  51. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
0, 0
0, 0
0, 0
1, 1
1, 1
1, 1