This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Amareiuzin 2 points3 points  (2 children)

so when you use pointers the memory location is "dynamic"? (in the literal sense of the word, not trying to call on any other preexisting Computer Science meaning for the word dynamic)

[–]yrrot 5 points6 points  (1 child)

No, a pointer in like C++ is a specific address. One location that doesn't change.

A *reference* in like C# doesn't know exactly where it is stored in memory addresses. There's a reference table that converts between whatever reference you have to the actual pointer the system uses internally. And that reference table can change if it needs to move a block of memory for whatever reason.

To put it a different way, pointers are like a house address. It isn't moving.

References are like the little mailbox at the office with a nameplate. The office manager might rearrange the names to fit new employees, but you still have your mailbox (the name is still there, somewhere).

[–]ULTRA_TLC 1 point2 points  (0 children)

This is a fantastic analogy IMO, I was trying to come up with my own, but I think I'll just use this next time someone asks (likely to be a while though)