Checkpoint: Copy & Move
intermediate35 min readLesson 91 of 204
One owning type with correct copy independence and a safe move — the Rule of Five in miniature.
Write Sentence with the full ownership discipline:
- one
std::vectormember means the compiler-generated copies are already deep — but write the five operations yourself to see the machinery joined()builds its string from words; no stored separator state- after
std::move(a),amust still be destructible (it will be — the vector member handles it) whilecowns the words
If your copy tests pass but assignment leaks or double-frees, you have re-discovered why the Rule of Three exists.