← Quiz: Memory and Smart Pointers: all 10 questions
Quiz: Memory and Smart Pointers · Question 2 of 10
What happens when you try to copy a uniqueptr?
What happens when you try to copy a unique_ptr?
- A.Both point to the object
- B.Compile error — it can only be moved
- C.The object is copied
- D.It becomes a shared_ptr
Answer & explanation
Correct answer: Compile error — it can only be moved
Single ownership means copying is disabled; use std::move.
Can you get the rest right without peeking?
Take the timed Quiz: Memory and Smart Pointers quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →