Skip to content
Related Articles

Related Articles

C++ | new and delete | Question 4
  • Last Updated : 13 Sep, 2013

What happens when delete is used for a NULL pointer?




int *ptr = NULL;
delete ptr; 

(A) Compiler Error
(B) Run-time Crash
(C) No Effect


Answer: (C)

Explanation: Deleting a null pointer has no effect, so it is not necessary to check for a null pointer before calling delete.

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :