What to use to access member functions
What sould be used to access member functions? With the objects themselves (ex. obj.function()) or with pointers? objPtr->function().
Which is more appropriate?
if the object is a pointer than you have to use the -> operator. if the object is a stack variable then you use the . operator.
If you have an regular ol' object use .
If you have a Pointer to an Object use ->
The only other option (I believe) would be (*object).method() if you were given a pointer, which is more comlicated, harder to read, more keystrokes not to mention pointless because you already have a perfectly good pointer. I suppose you could also do (&object)->method() given an object, but that's equally rediculous.
If you have a Pointer to an Object use ->
The only other option (I believe) would be (*object).method() if you were given a pointer, which is more comlicated, harder to read, more keystrokes not to mention pointless because you already have a perfectly good pointer. I suppose you could also do (&object)->method() given an object, but that's equally rediculous.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement