← Quiz: Move Semantics and rvalue References: all 10 questions
Quiz: Move Semantics and rvalue References · Question 6 of 10
After Buffer c = std::move(a);, what can you safely do with a?
After Buffer c = std::move(a);, what can you safely do with a?
- A.Read its old values, which are unchanged
- B.Destroy it or assign a new value to it
- C.Nothing; using a in any way is a compile error
- D.Only call delete on it
Answer & explanation
Correct answer: Destroy it or assign a new value to it
A moved-from object is valid but unspecified: it can be destroyed or reassigned, but its old value should not be relied on.
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 →