Interview Questions

Anything wrong with this code? T *p = new T[10]; delete p;

C++ Interview Questions and Answers


(Continued from previous question...)

Anything wrong with this code?
T *p = new T[10];
delete p;

Everything is correct, Only the first element of the array will be deleted”, The entire array will be deleted, but only the first element destructor will be called.

(Continued on next question...)

Other Interview Questions