• ### What is your GameDev Story?

Public Group

#### Archived

This topic is now archived and is closed to further replies.

# Analogies for pointers?

This topic is 6121 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Greetings all, I am taking a game design course and am struggling to get a grasp on *pointers, along with using the & (ampersand) sign. Question- How do you relate pointers and & in an analogy to best communicate how they are used, and where they are used in C++. Feel free to post your analogies. Hopefully this will help many, not just myself. "I Vanna Fryyyy Skyyyy Hiiiiiiigh! Vroooll to get Vyyy!" -Sega''''s "Daytona USA"

##### Share on other sites
Let's say you have a piece of paper. You place the piece of paper in your room. The piece of paper can't leave your room.

Let's say you can do only one thing in each room of your house. In the next room, you can rip pieces of paper up into little bits. What if you want to rip the original piece of paper?

You can make a copy of it, and rip it in the ripping room, but the paper in your room will still be intact.

The answer? Pointers. A pointer is like a portal to the piece of paper in your room. With the pointer, you can now directly edit the piece of paper and rip it up, without exiting the room where you can rip up paper. :-)

[edited by - UBC_Wiskatos on April 18, 2002 10:32:36 PM]

##### Share on other sites
When I was taking my intro CS courses in University I thought that analogies made things more complicated then they had to be. An int is a variable type right? Well if you say "int x" then the variable has to be stored somewhere in memory, at some particular address. You computer knows that when it looks at the 1''s and 0''s at that memory address that it should interpret them as a number. Well all a pointer is is a variable whose 1''s and 0''s should be interpreted by your computer as an address somewhere in memory. So if you have "int *p" then the 1''s and 0''s where p is stored tell you where some integer is stored in memory. Thats all a pointer is, there is nothing more complicated to them then that. It is a little more complicated to learn when/why/how to use them properly though.

Good Luck

##### Share on other sites
Lets say we are in the same room. We are separate entities taking up separate space. I am pointing at you (literally). If someone whats to find you they can follow where I am pointing and they will find you. Thats what pointers do except they do it for memory locations.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 31
• 16
• 11
• 10
• ### Forum Statistics

• Total Topics
634118
• Total Posts
3015610
×