C++ | new and delete | Question 4
What happens when delete is used for a NULL pointer?
int *ptr = NULL; delete ptr; |
chevron_right
filter_none
(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
Recommended Posts:
- C++ | new and delete | Question 5
- C++ | new and delete | Question 3
- C++ | new and delete | Question 2
- C++ | new and delete | Question 1
- "delete this" in C++
- delete and free() in C++
- C program to delete a file
- C | Arrays | Question 10
- C | Functions | Question 4
- C | Operators | Question 11
- C | Operators | Question 12
- C | Operators | Question 13
- C | Misc | Question 1
- C | Misc | Question 2
- C | Misc | Question 7

