-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconst_order.cpp
60 lines (56 loc) · 926 Bytes
/
const_order.cpp
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
54
55
56
57
58
59
60
#include <iostream>
using namespace std;
class Point {
int x_;
int y_;
public:
Point (int x, int y): x_(x), y_(y)
{
cout << "Point ctor" << endl;
print();
cout << "Point ctor complete" << endl;
}
~Point()
{
cout << "Point dtor" << endl;
print();
cout << "Point dtor complete" << endl;
}
void print()
{
cout << "x_ = " << x_ << "y_ = " << y_ << endl;
}
};
class Rect {
Point tl_;
Point br_;
public:
Rect(int tlx, int tly, int brx, int bry):tl_(tlx, tly), br_(brx, bry)
{
cout << "Rect ctor" << endl;
print();
cout << "Rect ctor complete" << endl;
}
~Rect()
{
cout << "Rect dtor" << endl;
print();
cout << "Rect dtor complete" << endl;
}
void print()
{
tl_.print();
cout << endl;
br_.print();
cout << endl;
}
};
int main()
{
cout << "In main start" << endl;
Rect r (1, 2, 3, 4);
cout << "In main" << endl;
r.print();
cout << "In main end" << endl;
return 0;
}