-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6_2.cpp
More file actions
46 lines (34 loc) · 800 Bytes
/
6_2.cpp
File metadata and controls
46 lines (34 loc) · 800 Bytes
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
46
#include <iostream>
using namespace std;
class Point {
private:
int x, y;
public:
Point(int x = 0, int y = 0) {
this->x = x;
this->y = y;
}
Point& move(int dx, int dy) {
this->x += dx;
this->y += dy;
return *this;
}
void print() {
cout << "Point is at (" << x << ", " << y << ")" << endl;
}
};
int main() {
int x, y;
cout << "Enter starting x and y: ";
cin >> x >> y;
Point p(x, y);
int dx1, dy1, dx2, dy2;
cout << "Enter dx and dy for first move: ";
cin >> dx1 >> dy1;
cout << "Enter dx and dy for second move: ";
cin >> dx2 >> dy2;
p.move(dx1, dy1).move(dx2, dy2);
p.print();
cout<<"24CE052_Pushti";
return 0;
}