Download presentation
Presentation is loading. Please wait.
1
Essential Class Operations
CSCE 121 J. Michael Moore
2
Dynamic Memory Using dynamic memory in classes adds a new set of things to consider. Memory Leaks Shallow Copy Inefficient Copy
3
Rule of Three If you have to implement one of the following, you need to implement the other two. Destructor Copy Constructor Copy Assignment
4
Rule of Three Address memory leaks.
If you have to implement one of the following, you need to implement the other two. Destructor Copy Constructor Copy Assignment Address memory leaks.
5
Rule of Three Address shallow copy.
If you have to implement one of the following, you need to implement the other two. Destructor Copy Constructor Copy Assignment Address shallow copy.
6
If you don’t do these, the classes will not function as expected!
Rule of Three Five If you have to implement one of the following, you need to implement the other two four. Destructor Copy Constructor Copy Assignment Move Constructor Move Assignment If you don’t do these, the classes will not function as expected!
7
Rule of Three Five If you have to implement one of the following, you need to implement the other two four. Destructor Copy Constructor Copy Assignment Move Constructor Move Assignment If you don’t do these, the classes will probably function. There will just be preventable inefficiencies!
8
Essential Operations Constructors from arguments Default Constructor
Destructor Copy Constructor Copy Assignment Move Constructor Move Assignment
9
Essential Operations Needed for all classes.
Constructors from arguments Default Constructor Destructor Copy Constructor Copy Assignment Move Constructor Move Assignment
10
Needed with dynamic memory,
Essential Operations Constructors from arguments Default Constructor Destructor Copy Constructor Copy Assignment Move Constructor Move Assignment Needed with dynamic memory, i.e. memory on the heap.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.