Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Difference between delete and delete[]?

Answer Posted / sachin mahajan

When we want to free a memory allocated to a pointer to an
object then "delete" is used.
Ex
int * p;
p=new int;
// now to free the memory
delete p;
But when we have allocated memory for array of objects like
int * p= new int(10); //pointer to an array of 10 integer
then to free memory equal to 10 integers
delete []p;
NOTE: One can free the memory even by "delete p;" But it
will free only the first element memory.


Is This Answer Correct ?    70 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a static element?

1068


What happens if a pointer is deleted twice?

1271


Const char *p , char const *p What is the difference between the above two?

1211


Can malloc be used in c++?

1073


What is unary operator? List out the different operators involved in the unary operator.

995


Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).

996


What is virtual destructor? What is its use?

1073


Which c++ operator cannot overload?

1012


How does work in c++?

1075


If a base class is an adt, and it has three pure virtual functions, how many of these functions must be overridden in its derived classes?

1073


Can a function take variable length arguments, if yes, how?

1008


Where can I run c++ program?

1064


What is a pointer how and when is it used?

1092


What is meaning of in c++?

1211


What is recursion?

2149