C++ Programming Question:
Anything wrong with this code?
T *p = new T[10];
delete p;

Answers:
Answer #1
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.
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.
Answer #2
T ** p = new T[10];
delete [] p;
T ** p = new T[10];
delete [] p;
Previous Question | Next Question |
What problems might the following macro bring to the application? | Anything wrong with this code? T *p = 0; delete p; |