The Wayback Machine - https://web.archive.org/web/20211010061815/https://www.geeksforgeeks.org/c-new-and-delete-question-4/
Skip to content
Related Articles

Related Articles

Improve Article

C++ | new and delete | Question 4

  • Last Updated : 28 Jun, 2021

What happens when delete is used for a NULL pointer?

Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.




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

My Personal Notes arrow_drop_up
Recommended Articles
Page :