-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint.cpp
More file actions
53 lines (49 loc) · 827 Bytes
/
point.cpp
File metadata and controls
53 lines (49 loc) · 827 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
47
48
49
50
51
52
53
#include <iostream>
#include "point.h"
using namespace std;
int Point::n = 0;
// định nghĩa hàm của class
void Point::TT(int x)
{
this->xVal += x;
this->yVal += x;
}
void Point::Show()
{
cout << this->xVal << " " << this->yVal << endl;
}
Point::Point() : xVal(0), yVal(0)
{
this->xVal = 1;
this->yVal = 2;
Point::n++;
}
Point::Point(const Point &p) : xVal(p.xVal), yVal(p.yVal)
{
// this->xVal = p.xVal;
// this->yVal = p.yVal;
Point::n++;
}
Point::Point(const int &x, const int &y) : xVal(x), yVal(y)
{
// this->xVal = x;
// this->yVal = y;
Point::n++;
}
Point::~Point()
{
Point::n--;
}
int main()
{
Point p1;
p1.Show();
Point p2(3, 4);
p2.Show();
p2.TT(2);
p2.Show();
Point p3(p2);
p3.TT(4);
p3.Show();
return 0;
}