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

How a pointer differs from a reference?

1347


What are guid? Why does com need guids?

1055


Is it possible to get the source code back from binary file?

1363


What is an iterator?

1195


What is the use of endl in c++?

1023


When we use Abstract Class and when we use Interface?where we will implement in real time?

2185


What is virtual destructor ans explain its use?

1130


What are static member functions?

1121


What is a forward referencing and when should it be used?

1166


What does count ++ do in c++?

1205


Tell me an example where stacks are useful?

1036


Keyword mean in declaration?

1061


Can comments be longer than one line?

1077


What are the two types of comments?

999


How can I improve my c++ skills?

1134