I picked up my data structures book and started reading it. First thing that came to my mind is, If I were a teacher, how would I explain to students on pointer concepts. Believe me, it is still a challenging concept to comprehend.
Pointer is a like a phone number to reach a person. Pointer points to address of the object that holds the data. Now, what is dangling reference. It is possible that there can be many pointer variables pointing to same address. For example, You, myself, someone else can have the same phone number of the person to reach. Question: What if the person dies? :) I still will have phone number, but cannot reach him or her. On top of that, what if that phone number gets assigned to some other person. In that case, I will reach the wrong person. The phone number I have is a dangling reference. Pointer pointing to the address, but address does not hold the desired object anymore ...
Simple, isnt it?
Comments
Post a Comment
Thanks for your comments.