-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraft.txt
More file actions
50 lines (42 loc) · 1.92 KB
/
draft.txt
File metadata and controls
50 lines (42 loc) · 1.92 KB
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
ChatBot::ChatBot(const ChatBot &source){
std::cout << "COPYING content of instance " << &source << " to instance " << this << std::endl;
_chatLogic = source._chatLogic;
_rootNode = source._rootNode;
_image = new wxBitmap(*source._image);
} // (2) copy constructor
ChatBot &ChatBot::operator=(const ChatBot &source){
std::cout << "ASSIGNING content of instance " << &source << " to instance " << this << std::endl;
if (this == &source)
return *this;
delete _image;
_image = new wxBitmap(*source._image);
_chatLogic = source._chatLogic;
_rootNode = source._rootNode;
return *this;
} // (3) overloading copy assignement operator
ChatBot::ChatBot(ChatBot &&source) {
std::cout << "MOVING (constructor) instance " << &source << " to instance " << this << std::endl;
_image = source._image;
_chatLogic = source._chatLogic;
_rootNode = source._rootNode;
source._image = nullptr;
source._chatLogic = nullptr;
source._rootNode = nullptr;
} // (4) Move constructor
ChatBot &ChatBot::operator=(ChatBot &&source) {
std::cout << "MOVING (assign) instance " << &source << " to instance " << this << std::endl;
if (this == &source)
return *this;
delete _image;
_image = source._image;
_chatLogic = source._chatLogic;
_rootNode =source._rootNode;
source._image = nullptr;
source._chatLogic = nullptr;
source._rootNode = nullptr;
return *this;
} // (5) overloading move assignement operator
ChatBot(const ChatBot &source); // (2) copy constructor
ChatBot &operator=(const ChatBot &source); // (3) overloading copy assignement operator
ChatBot(ChatBot &&source); // (4) Move constructor
ChatBot &operator=(ChatBot &&source); // (5) overloading move assignement operator