What is the difference between the dot (.) operator and -> in C++?
The following two expressions are equivalent:
(subject to operator overloading, as Konrad mentions, but that's unusual).
a->b is generally a synonym for
(*a).b. The parenthesises here are necessary because of the binding strength of the operators
*a.b wouldn't work because
. binds stronger and is executed first. This is thus equivalent to
Beware of overloading, though: Since both
* can be overloaded, their meaning can differ drastically.