Actually, few C++ programmers would write (*cptr).radius
or
(*cptr).volume ( )
. Instead, most would take advantage of the
class-pointer operator, ->
, which you can think of as a
shorthand that takes the place of both the dereferencing operator and the
class-member operator. Thus, the following are equivalent:
Equivalent (*cptr).radius <----------> cptr -> radius
The following are also equivalent:
Equivalent (*cptr).volume ( ) <----------> cptr -> volume ( )
Thus, the class-pointer operator takes the place of two other operators and eliminates the need for precedence-defeating parentheses.