What is the dangling pointer in c++

Showing Answers 1 - 2 of 2 Answers

Ashwan

  • Jul 26th, 2007
 

Dangling Pointer is a pointer pointing to either unallocated memory area or to the area that has already been freed. In simple words, Dangling pointer is the one that points no-where.

jaihind007

  • Jul 15th, 2008
 

Dangling pointer leads the memory leak problems. The following circumstances are memory leak ( dangling pointers ), not for good programming practice , try to avoid

1) Try to avoid the empty object pointer creation
2) Memory allocation without de allocation.
3) With out memory allocation , But de allocation.
4) Memory allocation , De allocation , But again unnecessary de allocation. 

Solution:

Make sure created object is set it to NULL pointer. While destructing the object deallocate the memory and set the object is NULL.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions