-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfriend-example-03.cpp
More file actions
49 lines (35 loc) · 809 Bytes
/
friend-example-03.cpp
File metadata and controls
49 lines (35 loc) · 809 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
//
// Created by jaco.ryu on 2019-07-14.
//
#include<iostream>
using namespace std;
class Rect;
class RectManager {
public:
bool equals(Rect s, Rect r);
void copy(Rect &dest, Rect &src);
};
class Rect {
int weight, height;
public:
Rect(int weight, int height) {
this->weight = weight;
this->height = height;
}
friend RectManager;
};
bool RectManager::equals(Rect s, Rect r) {
return s.weight == r.weight && s.height == r.height;
}
void RectManager::copy(Rect &dest, Rect &src) {
dest.weight = src.weight;
dest.height = src.height;
}
int main() {
Rect a(3,4), b(5,6);
RectManager man;
man.copy(b, a); // a를 b에 복사한다.
if(man.equals(a, b)) cout << "equal" << endl;
else cout << "not equal" << endl;
return 0;
}