结构(记录)

#include <iostream>
using namespace std;

struct Point {
    int x, y;

    string ToString() {
        return "x = " + to_string(x) +
             "; y = " + to_string(y);
    }

    void Move(int right, int down) {
        x += right;
        y += down;
    }
};

Point p1 {12};
string str1 = p1.ToString();
//str1 is "x = 1; y = 2"

p1.Move(5-1);
string str2 = p1.ToString();
//str2 is "x = 6; y = 1"

cout << "str1 is " << str1 << endl;
cout << "str2 is " << str2;