i just have a question are this the same if not why or why not.
Code:x.y // member y of object by x x->y menber y of object by x but am i passing by reference right?
This is a discussion on question for pointer within the C++ Programming forums, part of the General Programming Boards category; i just have a question are this the same if not why or why not. Code: x.y // member y ...
i just have a question are this the same if not why or why not.
Code:x.y // member y of object by x x->y menber y of object by x but am i passing by reference right?
No, x->y is equivalent to (*x).y, i.e., member y of object pointed to by x.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
When you use x.y, x is an object instance, but in the case x->y then x is a pointer to an object you have created and you are accessing member y through the pointer to that object rather than through the object instance itself.
x->y is the same as (*x).y
and
x.y is the same as (&x)->y
Edit: Laserlight is quick off the button when it comes to answering questions, lol.![]()
Last edited by Swarvy; 10-28-2010 at 10:22 PM.