0

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?

Community
  • 1
  • 1
dukevin
  • 22,384
  • 36
  • 82
  • 111

2 Answers2

4

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 )

crazyjul
  • 2,519
  • 19
  • 26
4

In the absence of overloading operator->, p->x is equivalent to (*p).x

Stuart Golodetz
  • 20,238
  • 4
  • 51
  • 80