Has Dangling Pointer (To?

Has Dangling Pointer (To?

Dangling pointers arise during object destruction, when an object that has an incoming reference is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory.

What is dangling pointer points to?

Dangling pointer occurs at the time of the object destruction when the object is deleted or de-allocated from memory without modifying the value of the pointer. In this case, the pointer is pointing to the memory, which is de-allocated.

What is a dangling pointer and give an example?

7. 72. A dangling pointer is a pointer that points to invalid data or to data which is not valid anymore, for example: Class *object = new Class(); Class *object2 = object; delete object; object = nullptr; // now object2 points to something which is not valid anymore.

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.