-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemp.cpp
62 lines (46 loc) · 1013 Bytes
/
temp.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
61
62
#include <iostream>
#include <memory>
using namespace std;
class Parent {
public:
void a() { cout << "Parent a" << endl; }
virtual void b() { cout << "Parent b" << endl; }
Parent() = default;
Parent(const Parent& p) {
cout << "Parent copy constructor" << endl;
}
Parent& operator=(const Parent& p) {
cout << "Parent operator=" << endl;
return *this;
}
// 복사 대입 연산자
Parent& operator=(const Parent&& p) {
cout << "Parent operator= &&" << endl;
return *this;
}
int c = 1;
int d = 2;
};
class Child : public Parent {
public:
void a() { cout << "Child a" << endl; }
void b() { cout << "Child b" << endl; }
int c = 3;
int d = 4;
};
int main() {
short result = 3;
result ^= 1;
cout << result << endl;
result ^= 1;
cout << result << endl;
Child c = Child();
Parent p = c;
p.b();
Child c2 = c;
shared_ptr<Parent> p_sptr = make_shared<Child>();
p_sptr->b();
Parent* p_ptr = new Child();
p_ptr->b();
return 0;
}