Search code examples
c++pointersdereference

C++ pointers difference between * and ->


Possible Duplicate:
C++: ptr->hello(); /* VERSUS */ (*ptr).hello();

Too bad I can't google this...

Could someone explain or point me to where I can find the difference between these two? I understand * is a dereferencing operator, what about the -> ? What's the difference?


Solution

  • a->b is a syntactic sugar for (*a).b

    The only special case is the object operator-> which is called when -> is used on an object. It can be used to "simulate" the object is a pointer ( as with smart references )