🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Delete the array it points to
  2. B.Leave it unchanged
  3. C.Set it to nullptr so the source's destructor does not free the stolen array
  4. 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 →