View Single Post
  #12   Spotlight this post!  
Unread 23-11-2008, 18:14
Joe Hershberger Joe Hershberger is offline
National Instruments
AKA: jhersh
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 1997
Location: Austin, TX
Posts: 148
Joe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to all
Re: Team 67 C++ Example Code

Quote:
Originally Posted by AustinSchuh View Post
-> and . can not be interchanged.

x->y() is a shortcut for (*x).y(), so you use . when x is an object, and -> when x is an pointer to an object. It is exactly the same as accessing members of a structure in C.
In C++, you can also define a "reference" to an object. References allow you to use the same syntax that you use with the object (object.method()), but you get the same behavior as a pointer (not copied, etc). WPILib for C++ makes use of references and use of them is recommended over pointers.
Reply With Quote