#include <iostream>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

struct Point {
    int x;
    int y;

    string toString() {
        ostringstream oss;
        oss << "(" << x << ", " << y << ")";
        return oss.str();
    }
};

class Point2 {
private:
    int _x;
    int _y;

public:
    Point2() {
        _x = 0;
        _y = 0;
    }

    Point2(int x, int y) {
        _x = x;
        _y = y;
    }

    Point2(const Point2& other) {
        _x = other._x;
        _y = other._y;
    }

    int x() {
        return _x;
    }

    int y() {
        return _y;
    }

    void moveTo(int x, int y) {
        _x = x;
        _y = y;
    }

    Point2& moveBy(int dx, int dy) {
        _x += dx;
        _y += dy;
        return *this;
    }

    string toString() {
        ostringstream oss;
        oss << "(" << _x << ", " << _y << ")";
        return oss.str();
    }
};

int main() {
    vector<Point2> vp2;
    for (int i = 1; i <= 5; ++i) {
        Point2 p2(i * 5, i * 10);
        vp2.push_back(p2);
    }
    for (auto p2 : vp2) {
        cout << p2.toString() << endl;
    }
    for (auto& p2 : vp2) {
        p2.moveBy(1, -1).moveBy(2, -2).moveBy(0, 0);
    }
    for (auto p2 : vp2) {
        cout << p2.toString() << endl;
    }

    Point2 pa(123, 456);
    Point2 pb = pa;
    cout << pa.toString() << " -> " << pb.toString() << endl;
    
    /*vector<Point> vp;
    for (int i = 1; i <= 5; ++i) {
        Point p = { .x = i * 5, .y = i * 10 };
        vp.push_back(p);
    }
    for (int i = 0; i < vp.size(); ++i) {
        cout << i << ": (" << vp[i].x << ", " << vp[i].y  << ")" << endl;
    }
    for (auto p : vp) {
        cout << "(" << p.x << ", " << p.y  << ")" << endl;
    }
    for (auto p : vp) {
        cout << p.toString() << endl;
    }*/

    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: