Operators in C and C++

Most of the operators available in C and C++ are also available in other C-family languages such as C#, D, Java, Perl, and PHP with the same precedence, associativity, and semantics.

In the following tables, lower case letters such as a and b represent literal values, object/variable names, or l-values, as appropriate.

Note that overloading logical AND and OR is discouraged, because as overloaded operators they always evaluate both operands instead of providing the normal semantics of short-circuit evaluation.

The ISO C specification makes allowance for these keywords as preprocessor macros in the header file iso646.h.

The ternary operator allows any arbitrary expression as its middle operand, despite being listed as having higher precedence than the assignment and comma operators.

Also, the immediate, un-parenthesized result of a C cast expression cannot be the operand of sizeof.

The precedence table determines the order of binding in chained expressions, when it is not expressly specified by parentheses.

The binding of operators in C and C++ is specified by a factored language grammar, rather than a precedence table.

[11][12] To use the comma operator in a function call argument expression, variable assignment, or a comma-separated list, use of parentheses is required.

Historically, there was no syntactic distinction between the bitwise and logical operators.

Precedence and bindings