+ 4
When to use . operator and when to use -> operator ?
. is direct access operator -> is indirect access operator Can anyone explain , please?
3 odpowiedzi
+ 15
The target. dot works on objects; arrow works on pointers to objects.
std::string str("foo"); std::string * pstr = new std::string("foo"); str.size (); pstr->size ();
The . operator is for direct member access.
object.Field
The arrow dereferences a pointer so you can access the object/memory it is pointing to
pClass->Field
https://stackoverflow.com/questions/11902791/what-is-the-difference-between-and-in-c
+ 32
http://www.cplusplus.com/forum/beginner/139181/
The (.) dot and The (->) arrow operator. - C++ Forum - Cplusplus.com
+ 5
Thank you very much Nithiwat and GAWEN STEASY