C++ Programming Question: Download C++ Programming PDF

Anything wrong with this code?
T *p = 0;
delete p;

Tweet Share WhatsApp

Answers:

Answer #1Yes, the program will crash in an attempt to delete a null pointer.

Answer #2Program will work just fine,if we write if(p !=0) delete p; then
this checking will be called 2 times,by you and by language implementation

Download C++ Programming PDF Read All 120 C++ Programming Questions
Previous QuestionNext Question
Anything wrong with this code?
T *p = new T[10];
delete p;
How do you decide which integer type to use?