19.1.  Operators

[ fromfile: operators.xml id: operators ]

Operators fall into broad classifications according to their primary use.

Assignment operators =, +=, *=, ...
Arithmetic operators +, -, *, /, %
Relational operators <, <=, >, >=, ==, !=
Logical operators &&, ||, !
Bitwise operators &, |, ^, ~, <<, >>
Memory management operators new, delete, sizeof
Pointer and access operators *, &, ., ->, [], ()
Scope resolution operators ::
Miscellaneous operatorsconditional(?:), comma(,)

The C++ standard defines certain keywords that act as aliases for some of the operator symbols:

Table 19.1. Operator Aliases

OperatorAlias
&& and
& bitand
&= and_eq
|| or
| bitor
|= or_eq
^ xor
^= xor_eq
! not
!= not_eq
~ compl

Operators have predefined meanings for built-in types, but not all operators are defined for all built-in types.

Operator Characteristics

Operators have the following special characteristics:

Table 19.2 lists all the C++ operators and their characteristics, grouped by precedence and purpose, with groups of highest precedence listed first.