difference between delete and delete[ ]
delete and delete[ ]
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Munesh SharmaPosted Apr 30, 2014, 1:31 AM
int *pi = new int; // allocates a single integer
int *pi_array = new int[10]; // allocates an array of 10 integers
delete pi;
pi = 0;
delete [] pi_array;
pi_array = 0;
Abhay ShankerPosted Apr 29, 2014, 10:55 AM
VulpesPosted Apr 29, 2014, 9:21 AM
In C++, delete is used to remove an object from memory which was created using new and delete[] is used to remove an array object which was created using new[].