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

  1. A.Both point to the object
  2. B.Compile error — it can only be moved
  3. C.The object is copied
  4. 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 →