I am reading some c++ code and am slightly confused by the correct interpretation of the parenthesized indirection operators. For example, in the line
b = ((aclass*)a)-> b
I cannot speed-read over that (aclass*)
part, that is the parenthesised indirection operator. Why are the parentheses needed and which ambiguity do they solve?
I tend to interpret the above as an instruction to define b
in the current scope by assigning it the value of the namesake member of aclass
-type object referenced by the pointer a
. That is, something like
b = (aclass *a)->b
Likewise, in another place there is a construction:
const aclass *a = (aclass*) b
I wonder whether I am misinterpreting the operators and their precedence, or I could do without those parentheses.
I have had a look at When do extra parentheses have an effect, other than on operator precedence?, but it sounds overly technical for me to spot an tip.