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...

What is dangling pointers?and what is memory leak?

Answer Posted / rishabh agrawal

A1 - Dangling pointer points to a memory location which is
being removed.
E.g.
int* a = new int;
int *b = a;
delete b;

Now a will be a dandling pointer.

A2 - Memory leaks occur when memory allocated to a pointer
is not deleted and the pointer goes out of scope. This
allocated memory never gets de-allocated and remains in the
heap until the system is restarted.
E.g.
void foo()
{
int* ptr = new int;
*ptr = 10;
...
...
}
Since ptr is allocated memory using 'new', but no 'delete'
is called, hence memory allocated to ptr will leak.

Is This Answer Correct ?    106 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is it called c++?

974


Should a constructor be public or private?

976


Why can templates only be implemented in the header file?

1060


What are the defining traits of an object-oriented language?

1134


How will you call C functions from C ++ and vice-versa?

1076


what is Loop function? What are different types of Loops?

1162


What is a class template?

1024


How would you find out if a linked-list is a cycle or not?

955


What is a storage class? Mention the storage classes in c++.

973


What is double in c++?

993


What is a breakpoint?

954


What is split a string in c++?

1127


What is pure virtual function?

1020


What data structure is fastest, on average, for retrieving data: a) Binary Tree b) Hash Table c) Stack

1020


How to demonstrate the use of a variable?

1047