Proper Class Design Part 3 - Operators, the Rule of Zero and the Rule of Three
Channel:
Subscribers:
2,640
Published on ● Video Link: https://www.youtube.com/watch?v=MRArxhYt6Dg
Overloaded Operators allow your classes to be used with things like +, -, /, [], and so forth. We typically use them with mathematical classes to have them act math-y, or we overload [] for array-like classes to make them array-y.
The Rule of Zero (which I usually follow) states that if you don't have any memory allocations or deallocations in your class, then you don't need a destructor, copy constructor, or assignment operator.
The Rule of Three (now the rule of Five, but w/e) states that if you do a allocation (such as new) in your constructor, you will need a destructor, a copy constructor, and an assignment (operator=) operator.
Other Videos By Bill Kerney
2022-01-31 | The Standard Library |
2022-01-31 | Evaluating Claims Pt 2., Invalid/Valid/Sound Arguments |
2022-01-29 | Ways of Knowing, Making an Argument |
2022-01-28 | Separate Compilation in C++ |
2022-01-27 | Unreal Engine Materials in 20 minutes |
2022-01-27 | ARM32 - Dynamic Arrays, Classes in Assembly |
2022-01-26 | Sorting Objects in C++, The Rule of 3 |
2022-01-25 | Ludology: Principles of Game Design |
2022-01-25 | BVHs, Line x Box Intersection, Convex Hulls |
2022-01-25 | ARM32 Assembly - Logical Operators, Shifting, Arrays, Syscalls |
2022-01-25 | Proper Class Design Part 3 - Operators, the Rule of Zero and the Rule of Three |
2022-01-24 | What is Truth? |
2022-01-21 | Proper Class Design Part 2 |
2022-01-21 | Welcome to CSCI 1! |
2022-01-21 | UE5 - Quick Intro |
2022-01-21 | ARM32 Assembly - Functions |
2022-01-20 | "Proper" Class Design in C++, Part 1 |
2022-01-20 | Zeta - Bottom Up Solution |
2022-01-20 | Zeta - Top Down Coding Solution |
2022-01-18 | Acceleration Structures |
2022-01-18 | Intro to Unreal Engine 4 |
Tags:
csci 41
rule of zero
c++
rule of three
proper class design
oop
operators
operator overloading