Monday, January 08, 2007 6:55 PM
What is a Dangling Pointer? This has often been asked by my students. Here comes the answer.
A dangling pointer is one that points to an object that has already been deleted. As an example, let p1 and p2 be two pointers that are pointing to an object obj. If we delete one of these pointers, say, p1, the other pointer p2 becomes dangling. The following example would illustrate this better.
test *p1 = new test();
test *p2 = p1; //Now p1 and p2 both point to the same object.
p1->display(); //The pointer p1 is dangling!
An industry experience of over 10 years. Worked extensibly in Microsoft Technologies. Working in .Net and C# for over 5 years. Skills include,
I am currently working as a Technical Architect in a reputed MNC in Hyderabad, India. I have authored a lot of articles on .NET and its related technologies at ASPALLIANCE, DEVX, ASPNETPRO, CODERSOURCE, SQL-SERVER-PERFORMANCE.COM, SSWUG, etc.
Mail ID: firstname.lastname@example.org
I blog at: http://aspadvice.com/blogs/joydip/