Question 10
Back to Exercise
What happens if you delete p.get(); for a unique_ptr p?
- A Nothing special
- B Double delete (undefined behaviour) when p later deletes the same object Correct
- C p becomes null
- D Compile error
Correct Answer: Option B
get() returns a non-owning pointer; never delete it.
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!