Question 15
Back to Exercise
Which smart pointer correctly owns new int[100]?
- A std::unique_ptr<int>
- B std::unique_ptr<int[]> (it calls delete[]) Correct
- C std::weak_ptr<int>
- D Any of them
Correct Answer: Option B
unique_ptr<int> would call delete instead of delete[] – undefined behaviour.
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!