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

Which operator cannot be overloaded c++?

1006


Why is standard template library used?

1036


Can a program run without main?

1221


Why do we use classes in programming?

1026


What are different types of loops in c++?

1120


What is using namespace std in cpp?

1139


What is a virtual destructor? Explain the use of it?

981


What does namespace mean in c++?

1068


What is the meaning of c++?

1017


What is the difference between while and do while loop? Explain with examples.

1103


Which bitwise operator is used to check whether a particular bit is on or off?

1052


When is the copy constructor called?

1126


What does the following code do: int c=0; cout< a) Undefined *Updated* b) 01 c) 00

1060


Given the following seqment of code containing a group of nested if instructions: y = 9; if ((x==3) || (x == 5)) y++; else if (x == 2) y *= 2; else if (x == ) y-= 7; else y = 8; if the value of x is 4 before the nested IFs are executed, what is the value of y after the nested IFs are executed?

2010


Explain the difference between static and dynamic binding of functions?

1052