View Single Post
  #8   Spotlight this post!  
Unread 21-03-2012, 20:40
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: C++ help: Understanding pointers?

My professor (from the dark ages) explained pointers like this. Think of memory as a bunch of numbered mailboxes. If you declare a simple variable that is like going to a mailbox (the address) and getting your letter (data). A pointer is going to a mailbox (address of the pointer) and getting a slip of paper that has another mailbox number (address of the data) on it. You then open the next mailbox and their is your letter (data). Make sense?

Pointers are not just an arbitrary concept put in languages to cause us headaches. They mirror capabilities in the hardware. Most computers have machine instructions that use "indirect addressing" or "indirected indexed addressing" modes. Pointers in C and C++ are indirect addressing in a high level language.

Anyways - add the concept that pointers increment by the size of the object they point to (so incrementing a pointer to an integer adds 4) and you are good to go.
__________________
Fast, cheap or working - pick any two!

Last edited by wireties : 22-03-2012 at 15:47.