foo->bar()
is the same as (*foo).bar()
.
The parenthesizes above are necessary because of the binding strength of the *
and .
operators.
*foo.bar()
wouldn't work because Dot (.
) operator is evaluated first (see operator precedence)
The Dot (.
) operator can't be overloaded, arrow (->
) operator can be overloaded.
The Dot (.
) operator can't be applied to pointers.
Also see: What is the arrow operator (->) synonym for in C++?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…