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
|
#ifndef __POS_H
#define __POS_H
#include <iostream>
using namespace std;
class Pos {
int x, y;
public:
int getx() {
return x;
}
int gety() {
return y;
}
Pos();
Pos(int, int);
Pos operator+(Pos);
friend ostream &operator<<(ostream &, Pos &);
};
Pos::Pos(int x, int y) {
this->x = x;
this->y = y;
}
Pos::Pos() {
x = 0;
y = 0;
}
Pos Pos::operator+(Pos other) {
return Pos(this->x + other.x, this->y + other.y);
}
ostream &operator<<(ostream &stream, Pos &pos) {
stream << "(" << pos.x << ", " << pos.y << ")";
return stream;
}
#endif
|