1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
using namespace std;
template<class T>
class Point {
private:
T x;
T y;
public:
void set_x(const T &x) {
this->x = x;
}
void set_y(const T &y) {
this->y = y;
}
T get_x() const {
return x;
}
T get_y() const {
return y;
}
void reflect() {
x = -x;
y = -y;
}
};
int main() {
Point<int> p;
p.set_x(1);
p.set_y(2);
cout << '(' << p.get_x() << ',' << p.get_y() << ')' << endl;
p.reflect();
cout << '(' << p.get_x() << ',' << p.get_y() << ')' << endl;
return 0;
}
Enter to Rename, Shift+Enter to Preview