Week 3 Lecture 3 - The Rule of 3

Channel:
Subscribers:
2,640
Published on ● Video Link: https://www.youtube.com/watch?v=drzAZt6peDU



Duration: 1:32:35
185 views
1


Learning points for today:

1) Auto deduces the type from the right hand side of the assignment
2) You can make anonymous variables and functions and classes and parameters, etc.
3) Operators can be used to convert types, unless you use the explicit keyword
4) Global operators vs member operators
5) Copy constructors are necessary when you're allocating something in cstor / deallocating in dstor

Rule of 0 - No news is good news - write code that doesn't need copy constructors, assignment operators, etc. This is how I usually operate these days.
Rule of 3 - if you are allocating something in your cstor, and you need one of these, you probably need all of these: dstor, copy cstor, operator=
Rule of 5 - adds two move cstors to the rule of 3







Tags:
csci 41
data structures
adt
class design
rule of 3