What would be a good real world metaphor to use to describe pointers in C?

c, pointers

Solution

I always liked the analogy that a pointer is like your finger. If I take you to a parking lot and ask you to find me a red car, you extend one finger (of your choice ;)) and point to a red car.

Your finger is not the answer. Your finger tells me nothing, but if I look where you're finger is pointing to, I can find what I was looking for.

Now I can ask you to find a blue car and you can redirect your finger (reassign) it to a new car. Now your pointer (the same one as before) is showing me new data of the same type. The pointer hasn't change, just what it is pointing to.

This works with more than one pointer as well. I can ask where is the pointer pointing to the blue car and you can use your other hand and point with a finger to the first finger. Now if I want to know where the blue car is I can follow the first finger's direction to the second finger, to the car (the data).

Problem

I find that I learn best through real-world comparison metaphors. For example, in java, one way that helped me understand the concept of Accessors and Mutators really well was thinking of it through the concept of a middle man (the private variables don't like to deal with their clients directly, they prefer to have a middle man(the accessors and mutators) handle them) The concept of pointers in C is still kinda tricky for me. What would be a good metaphor to use to describe how they work?

Original source

Related problems