View Single Post
  #5   Spotlight this post!  
Unread 29-10-2008, 18:12
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 800
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: Team 67 C++ Example Code

Quote:
Originally Posted by Tom Line View Post
I still don't get the reason behind wanting to use a pointer rather than just a variable.
Say you have a structure. It has a variable in it that you want to modify with a function. If you were to just pass the structure into the function, the compiler would pass a copy of the structure to the function, so any changes you did to the structure wouldn't change the original. This isn't the behavior you want. So instead, you pass a pointer to the structure to the function. That pointer is a number saying where the structure is in memory, so when the compiler makes a copy of the pointer to pass into the function, that still points to the correct place in memory. You can then modify the structure in your function, and it all works.

I can try to clarify later, if someone else doesn't beat me to it, if that was confusing.
Reply With Quote