I read that delete[]
can deallocate an array of objects. However it is not mentioned in any of the sources I've read that whether it is an error or undefined to supply an argument like delete[3]
.
I have the following queries.
- Is it specified in C++ standard whether I can/cannot suplly a parameter to
delete[]
asdelete[3]
? - If yes, what is the effect?
- Also is it specified in C++ whether I can/cannot use
delete
for an array allocated fromnew[]
?
delete array[3]
which delets whateverarray[3]
points to (so if you have an array of pointers), and doesn't deletearray
or some part of it. Deleting a subarray is not possible, if you want to do that. – Cowcatcherdelete array[3]
, for the bookshelf it'sdelete[] array
. I hope this analogy is somewhat helpful. – Cowcatcher