previous | start | next

9. Precedence

Warning: It would be incorrect to write

 *p.addGas(20);     
         

There are two operators - the dereferencing operator * and the member access operator - .

Which one executes first? That is, which one has higher precedence?

The dot operator (member access) has higher precedence. So the parentheses are necessary. The variable p is not of type Car; its type is pointer to a Car.



previous | start | next