C++ Syntax: Precedence

C++ has a large operator set, as the table below testifies. When an expression involves two or more operators, two rules are applied to determine the meaning of the expression:-
  1. Priority - Higher priority operators take priority over lower priority ones. So, as every FORTRAN programmer knows,:-
    2 + 3 * 5
    
    is 17 not 30. In the table operators are ordered in decreasing priority, although operators within a single box, for example add and subtract, operate at the same priority.

  2. Association - When selecting between two operators of the same priority, they operate according to their associativity, which is either:-