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 2
- C++ | new and delete | Question 3
- "delete this" in C++
- delete and free() in C++
- C program to delete a file
- new vs malloc() and free() vs delete in C++
- C | String | Question 14
- C++ | Constructors | Question 16
- C++ | this pointer | Question 2
- C++ | this pointer | Question 1
- C++ | Constructors | Question 9
- C++ | Destructors | Question 3
- C++ | Constructors | Question 8