Quote:
Originally Posted by AustinSchuh
-> 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.