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

Can java be faster than c++?

1153


Why do we use structure in c++?

1075


How does com provide language transparency?

1010


Should the this pointer can be used in the constructor?

1021


What doescout<<(0==0) print out a) 0 b) 1 c) Compiler error: Lvalue required

968


Is it possible to pass an object of the same class in place of object reference to the copy constructor?

1044


Explain about vectors in c ++?

1025


What is the difference between strcpy() and strncpy()?

1143


What is the best ide for c++?

1094


How much do c++ programmers make?

1107


What is the importance of mutable keyword?

1022


Can a new be used in place of old mallocq? If yes, why?

1096


Why null pointer is used?

1046


Explain about Virtual Function in C++?

1023


describe private access specifiers?

1235