Possible Duplicate:
What is the difference between the dot (.) operator and -> in C++?
C++ has the following member selection operators: .
and ->
.
What is the main difference between them?
Thanks.
Possible Duplicate:
What is the difference between the dot (.) operator and -> in C++?
C++ has the following member selection operators: .
and ->
.
What is the main difference between them?
Thanks.
.
is used with non-pointers, while ->
is used with pointers, to access members!
Sample s;
Sample *pS = new Sample();
s.f() ; //call function using non-pointer object
pS->f(); //call the same function, using pointer to object
.
cannot be overloaded, while ->
can be overloaded.
pointer2object->member()
is equal to
(*pointer2object).member()
and is made for more convinience, as I suppose.