← Quiz: Move Semantics and rvalue References: all 10 questions
Quiz: Move Semantics and rvalue References · Question 4 of 10
What should a move constructor do with the source object's pointer?
What should a move constructor do with the source object's pointer?
- A.Delete the array it points to
- B.Leave it unchanged
- C.Set it to nullptr so the source's destructor does not free the stolen array
- D.Make a deep copy of the array
Answer & explanation
Correct answer: Set it to nullptr so the source's destructor does not free the stolen array
The new object now owns the array; the source must give up ownership or the array is deleted twice.
Can you get the rest right without peeking?
Take the timed Quiz: Move Semantics and rvalue References quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →