Is it fine to call delete twice for a pointer?
Explanation: It is undefined behavior to call delete twice on a pointer.
Anything can happen, the program may crash or produce nothing.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- C++ | new and delete | Question 1
- C++ | new and delete | Question 4
- C++ | new and delete | Question 3
- C++ | new and delete | Question 2
- "delete this" in C++
- delete and free() in C++
- new vs malloc() and free() vs delete in C++
- C program to delete a file
- C Quiz - 104 | Question 2
- C Quiz - 107 | Question 5
- C Quiz - 102 | Question 4
- C Quiz - 103 | Question 4
- C Quiz - 104 | Question 1
- C Quiz - 103 | Question 5
- C Quiz - 102 | Question 5