Caffeinated Coder
Book an appointment
Lesson 15 · Classes

Copy and move

An object that owns memory can be copied or moved. A copy makes a new block and copies every element into it, so the two objects are independent. A move hands the existing block to the new object and leaves the old one empty, so nothing is copied. Follow a std::vector through one copy, one move and the end of its scope, then see the rule of five and the rule of zero.

11 min9 steps5 questionsIntermediate
Fig 15 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.