Question 2
Back to Exercise
What happens with auto b = a; when a is a std::unique_ptr?
- A Both point to the object
- B Compile error – unique_ptr is move-only; use std::move(a) Correct
- C The object is copied
- D a is deleted
Correct Answer: Option B
Moving transfers ownership and leaves a empty.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!