ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.1 months ago (distributed domain, exempt) |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B |
| Last Crawled | 2026-04-10 23:30:59 (4 days ago) |
| First Indexed | 2013-09-09 23:40:17 (12 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Operators in C and C++ - Wikipedia |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | From Wikipedia, the free encyclopedia
This is a list of
operators
in the
C
and
C++
programming languages
.
All listed operators are in C++ and lacking indication otherwise, in C as well. Some tables include a "In C" column that indicates whether an operator is also in C. Note that C does not support
operator overloading
.
When not overloaded, for the operators
&&
,
||
, and
,
(the
comma operator
), there is a
sequence point
after the evaluation of the first operand.
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.
Many operators specified by a sequence of symbols are commonly referred to by a name that consists of the name of each symbol. For example,
+=
and
-=
are often called "plus equal(s)" and "minus equal(s)", instead of the more verbose "assignment by addition" and "assignment by subtraction".
In the following tables, lower case letters such as
a
and
b
represent literal values, object/variable names, or l-values, as appropriate.
R
,
S
and
T
stand for a data type, and
K
for a class or enumeration type. Some operators have alternative spellings using
digraphs and trigraphs
or
operator synonyms
.
C and C++ have the same arithmetic operators and all can be overloaded in C++.
Operation
Syntax
C++ prototype
in class K
outside class
Addition
a
+
b
R
K
::
operator
+
(
S
b
);
R
operator
+
(
K
a
,
S
b
);
Subtraction
a
-
b
R
K
::
operator
-
(
S
b
);
R
operator
-
(
K
a
,
S
b
);
Unary
plus;
integer promotion
+
a
R
K
::
operator
+
();
R
operator
+
(
K
a
);
Unary
minus;
additive inverse
-
a
R
K
::
operator
-
();
R
operator
-
(
K
a
);
Multiplication
a
*
b
R
K
::
operator
*
(
S
b
);
R
operator
*
(
K
a
,
S
b
);
Division
a
/
b
R
K
::
operator
/
(
S
b
);
R
operator
/
(
K
a
,
S
b
);
Modulo
[
a
]
a
%
b
R
K
::
operator
%
(
S
b
);
R
operator
%
(
K
a
,
S
b
);
Prefix
increment
++
a
R
&
K
::
operator
++
();
R
&
operator
++
(
K
&
a
);
Postfix increment
a
++
R
K
::
operator
++
(
int
);
[
b
]
R
operator
++
(
K
&
a
,
int
);
[
b
]
Prefix
decrement
--
a
R
&
K
::
operator
--
();
R
&
operator
--
(
K
&
a
);
Postfix decrement
a
--
R
K
::
operator
--
(
int
);
[
b
]
R
operator
--
(
K
&
a
,
int
);
[
b
]
All
relational
(comparison) operators can be overloaded in C++. Since
C++20
, the inequality operator is automatically generated if
operator==
is defined and all four relational operators are automatically generated if
operator<=>
is defined.
[
1
]
Operation
Syntax
In C
C++ prototype
in class K
outside class
Equal to
a
==
b
Yes
bool
K
::
operator
==
(
S
const
&
b
)
const
;
bool
operator
==
(
K
const
&
a
,
S
const
&
b
);
Not equal to
a
!=
b
Yes
bool
K
::
operator
!=
(
S
const
&
b
)
const
;
bool
operator
!=
(
K
const
&
a
,
S
const
&
b
);
Greater than
a
>
b
Yes
bool
K
::
operator
>
(
S
const
&
b
)
const
;
bool
operator
>
(
K
const
&
a
,
S
const
&
b
);
Less than
a
<
b
Yes
bool
K
::
operator
<
(
S
const
&
b
)
const
;
bool
operator
<
(
K
const
&
a
,
S
const
&
b
);
Greater than or equal to
a
>=
b
Yes
bool
K
::
operator
>=
(
S
const
&
b
)
const
;
bool
operator
>=
(
K
const
&
a
,
S
const
&
b
);
Less than or equal to
a
<=
b
Yes
bool
K
::
operator
<=
(
S
const
&
b
)
const
;
bool
operator
<=
(
K
const
&
a
,
S
const
&
b
);
Three-way comparison
[
c
]
[
d
]
a
<=>
b
No
auto
K
::
operator
<=>
(
const
S
&
b
);
auto
operator
<=>
(
const
K
&
a
,
const
S
&
b
);
C and C++ have the same logical operators and all can be overloaded in C++.
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
.
[
2
]
Operation
Syntax
C++ prototype
in class K
outside class
NOT
!
a
bool
K
::
operator
!
();
bool
operator
!
(
K
a
);
AND
a
&&
b
bool
K
::
operator
&&
(
S
b
);
bool
operator
&&
(
K
a
,
S
b
);
OR
a
||
b
bool
K
::
operator
||
(
S
b
);
bool
operator
||
(
K
a
,
S
b
);
C and C++ have the same bitwise operators and all can be overloaded in C++.
Operation
Syntax
C++ prototype
in class K
outside class
NOT
~
a
R
K
::
operator
~
();
R
operator
~
(
K
a
);
AND
a
&
b
R
K
::
operator
&
(
S
b
);
R
operator
&
(
K
a
,
S
b
);
OR
a
|
b
R
K
::
operator
|
(
S
b
);
R
operator
|
(
K
a
,
S
b
);
XOR
a
^
b
R
K
::
operator
^
(
S
b
);
R
operator
^
(
K
a
,
S
b
);
Shift
left
[
e
]
a
<<
b
R
K
::
operator
<<
(
S
b
);
R
operator
<<
(
K
a
,
S
b
);
Shift right
[
e
]
[
f
]
a
>>
b
R
K
::
operator
>>
(
S
b
);
R
operator
>>
(
K
a
,
S
b
);
C and C++ have the same assignment operators and all can be overloaded in C++.
For the combination operators,
a ⊚= b
(where
⊚
represents an operation) is equivalent to
a = a ⊚ b
, except that
a
is evaluated only once.
Operation
Syntax
C++ prototype
in class K
outside class
Assignment
a
=
b
R
&
K
::
operator
=
(
S
b
);
N/a
Addition combination
a
+=
b
R
&
K
::
operator
+=
(
S
b
);
R
&
operator
+=
(
K
&
a
,
S
b
);
Subtraction combination
a
-=
b
R
&
K
::
operator
-=
(
S
b
);
R
&
operator
-=
(
K
&
a
,
S
b
);
Multiplication combination
a
*=
b
R
&
K
::
operator
*=
(
S
b
);
R
&
operator
*=
(
K
&
a
,
S
b
);
Division combination
a
/=
b
R
&
K
::
operator
/=
(
S
b
);
R
&
operator
/=
(
K
&
a
,
S
b
);
Modulo combination
a
%=
b
R
&
K
::
operator
%=
(
S
b
);
R
&
operator
%=
(
K
&
a
,
S
b
);
Bitwise AND combination
a
&=
b
R
&
K
::
operator
&=
(
S
b
);
R
&
operator
&=
(
K
&
a
,
S
b
);
Bitwise OR combination
a
|=
b
R
&
K
::
operator
|=
(
S
b
);
R
&
operator
|=
(
K
&
a
,
S
b
);
Bitwise XOR combination
a
^=
b
R
&
K
::
operator
^=
(
S
b
);
R
&
operator
^=
(
K
&
a
,
S
b
);
Bitwise left shift combination
a
<<=
b
R
&
K
::
operator
<<=
(
S
b
);
R
&
operator
<<=
(
K
&
a
,
S
b
);
Bitwise right shift combination
[
g
]
a
>>=
b
R
&
K
::
operator
>>=
(
S
b
);
R
&
operator
>>=
(
K
&
a
,
S
b
);
Operation
Syntax
Can overload
In C
C++ prototype
in class K
outside class
Subscript
a
[
b
]
a
<:
b
:>
[
4
]
Yes
Yes
R
&
K
::
operator
[](
S
b
);
R
&
K
::
operator
[](
S
b
,
...);
[
h
]
N/a
Indirection
(object pointed to by
a
)
*
a
Yes
Yes
R
&
K
::
operator
*
();
R
&
operator
*
(
K
a
);
Address-of
(address of
a
)
&
a
Yes
[
i
]
Yes
R
*
K
::
operator
&
();
R
*
operator
&
(
K
a
);
Structure dereference
(member
b
of object pointed to by
a
)
a
->
b
Yes
Yes
R
*
K
::
operator
->
();
[
j
]
N/a
Structure reference
(member
b
of object
a
)
a
.
b
No
Yes
N/a
Member selected by
pointer-to-member
b
of object pointed to by
a
[
k
]
a
->*
b
Yes
No
R
&
K
::
operator
->*
(
S
b
);
R
&
operator
->*
(
K
a
,
S
b
);
Member of object
a
selected by
pointer-to-member
b
a
.*
b
No
No
N/a
Operation
Syntax
Can overload
In C
C++ prototype
in class K
outside class
Function
call
a
(
a1, a2
)
Yes
Yes
R
K::operator
()(
S
a
,
T
b
,
...);
N/a
Comma
a
,
b
Yes
Yes
R
K
::
operator
,(
S
b
);
R
operator
,(
K
a
,
S
b
);
Ternary conditional
a
?
b
:
c
No
Yes
N/a
Scope resolution
a
::
b
[
l
]
No
No
N/a
User-defined literals
[
m
]
[
n
]
"a"_b
Yes
No
N/a
R
operator
""
_b
(
T
a
)
Sizeof
sizeof
a
[
o
]
sizeof
(R)
No
Yes
N/a
Size of
parameter pack
[
n
]
sizeof...
(Args)
No
No
N/a
Alignof
[
n
]
alignof
(R)
or
_Alignof
(R)
[
p
]
No
Yes
N/a
Typeof
[
q
]
typeof
(a)
typeof
(R)
typeof_unqual
(a)
typeof_unqual
(R)
N/a
Yes
N/a
Decltype
[
n
]
decltype
(a)
decltype
(R)
No
No
N/a
Type identification
typeid
(a)
typeid
(R)
No
No
N/a
Conversion
(C-style cast)
(R)a
Yes
Yes
K
::
operator
R
();
[
5
]
N/a
Conversion
[
r
]
[
6
]
R(a)
R{a}
[
n
]
auto(a)
[
h
]
auto{a}
[
h
]
No
No
N/a
static_cast
conversion
[
s
]
static_cast
<R>(a)
Yes
No
K
::
operator
R
();
explicit
K
::
operator
R
();
[
n
]
N/a
dynamic cast
conversion
dynamic_cast
<R>(a)
No
No
N/a
const_cast
conversion
const_cast
<R>(a)
No
No
N/a
reinterpret_cast
conversion
reinterpret_cast
<R>(a)
No
No
N/a
Allocate memory
new
R
[
t
]
Yes
No
void
*
K
::
operator
new
(
size_t
x
);
void
*
operator
new
(
size_t
x
);
Allocate array
new
R
[
n
]
[
u
]
Yes
No
void
*
K
::
operator
new
[](
size_t
a
);
void
*
operator
new
[](
size_t
a
);
Deallocate memory
delete
a
Yes
No
void
K
::
operator
delete
(
void
*
a
);
void
operator
delete
(
void
*
a
);
Deallocate array
delete[]
a
Yes
No
void
K
::
operator
delete
[](
void
*
a
);
void
operator
delete
[](
void
*
a
);
Exception check
[
n
]
noexcept
(a)
No
No
N/a
Reflection
[
v
]
^^
a
No
No
N/a
C++ defines keywords to act as aliases for a number of operators:
[
7
]
Keyword
Operator
and
&&
and_eq
&=
bitand
&
bitor
|
compl
~
not
!
not_eq
!=
or
||
or_eq
|=
xor
^
xor_eq
^=
Each keyword is a different way to specify an operator and as such can be used instead of the corresponding symbolic variation. For example,
(a > 0 and not flag)
and
(a > 0 && !flag)
specify the same behavior. As another example, the
bitand
keyword may be used to replace not only the
bitwise-and
operator but also the
address-of
operator, and it can be used to specify reference types (e.g.,
int bitand ref = n
).
The ISO C specification makes allowance for these keywords as preprocessor macros in the header file
iso646.h
. For compatibility with C, C++ also provides the header
iso646.h
, the inclusion of which has no effect. Until C++20, it also provided the corresponding header
ciso646
which had no effect as well.
Expression evaluation order
[
edit
]
During expression evaluation, the order in which sub-expressions are evaluated is determined by
precedence
and
associativity
. An operator with higher precedence is evaluated before a operator of lower precedence and the operands of an operator are evaluated based on associativity. The following table describes the precedence and associativity of the C and C++ operators. Operators are shown in groups of equal precedence with groups ordered in descending precedence from top to bottom (lower order is higher precedence).
[
8
]
[
9
]
[
10
]
Operator precedence is not affected by overloading.
Order
Operator
Description
Associativity
1
highest
::
Scope resolution
(C++ only)
None
2
++
Postfix increment
Left-to-right
--
Postfix decrement
()
Function call
[]
Array subscripting
.
Element selection by reference
->
Element selection through pointer
typeid()
Run-time type information
(C++ only) (see
typeid
)
const_cast
Type cast (C++ only) (see
const_cast
)
dynamic_cast
Type cast (C++ only) (see
dynamic cast
)
reinterpret_cast
Type cast (C++ only) (see
reinterpret_cast
)
static_cast
Type cast (C++ only) (see
static_cast
)
3
++
Prefix increment
Right-to-left
--
Prefix decrement
+
Unary plus
-
Unary minus
!
Logical NOT
~
Bitwise NOT (
ones' complement
)
(
type
)
Type cast
*
Indirection (dereference)
&
Address-of
sizeof
Sizeof
_Alignof
Alignment requirement (since C11)
new
,
new[]
Dynamic memory allocation (C++ only)
delete
,
delete[]
Dynamic memory deallocation (C++ only)
4
.*
Pointer to member (C++ only)
Left-to-right
->*
Pointer to member (C++ only)
5
*
Multiplication
Left-to-right
/
Division
%
Modulo
(remainder)
6
+
Addition
Left-to-right
-
Subtraction
7
<<
Bitwise
left shift
Left-to-right
>>
Bitwise
right shift
8
<=>
Three-way comparison
(Introduced in
C++20
- C++ only)
Left-to-right
9
<
Less than
Left-to-right
<=
Less than or equal to
>
Greater than
>=
Greater than or equal to
10
==
Equal to
Left-to-right
!=
Not equal to
11
&
Bitwise AND
Left-to-right
12
^
Bitwise XOR (exclusive or)
Left-to-right
13
|
Bitwise OR (inclusive or)
Left-to-right
14
&&
Logical AND
Left-to-right
15
||
Logical OR
Left-to-right
16
co_await
Coroutine processing (C++ only)
Right-to-left
co_yield
17
?:
Ternary conditional operator
Right-to-left
=
Direct assignment
+=
Assignment by sum
-=
Assignment by difference
*=
Assignment by product
/=
Assignment by quotient
%=
Assignment by remainder
<<=
Assignment by bitwise left shift
>>=
Assignment by bitwise right shift
&=
Assignment by bitwise AND
^=
Assignment by bitwise XOR
|=
Assignment by bitwise OR
throw
Throw operator (exceptions throwing, C++ only)
18
lowest
,
Comma
Left-to-right
Although this table is adequate for describing most evaluation order, it does not describe a few details. The
ternary operator
allows any arbitrary expression as its middle operand, despite being listed as having higher precedence than the assignment and comma operators. Thus
a ? b, c : d
is interpreted as
a ? (b, c) : d
, and not as the meaningless
(a ? b), (c : d)
. So, the expression in the middle of the conditional operator (between
?
and
:
) is parsed as if parenthesized. Also, the immediate, un-parenthesized result of a C cast expression cannot be the operand of
sizeof
. Therefore,
sizeof (int) * x
is interpreted as
(sizeof(int)) * x
and not
sizeof ((int) * x)
.
Chained expressions
[
edit
]
The precedence table determines the order of binding in chained expressions, when it is not expressly specified by parentheses.
For example,
++x*3
is ambiguous without some precedence rule(s). The precedence table tells us that:
x
is 'bound' more tightly to
++
than to
*
, so that whatever
++
does (now or later—see below), it does it ONLY to
x
(and not to
x*3
); it is equivalent to (
++x
,
x*3
).
Similarly, with
3*x++
, where though the post-fix
++
is designed to act AFTER the entire expression is evaluated, the precedence table makes it clear that ONLY
x
gets incremented (and NOT
3*x
). In fact, the expression (
tmp=x++
,
3*tmp
) is evaluated with
tmp
being a temporary value. It is functionally equivalent to something like (
tmp=3*x
,
++x
,
tmp
).
Precedence and bindings
Abstracting the issue of precedence or binding, consider the diagram above for the expression 3+2*y[i]++. The compiler's job is to resolve the diagram into an expression, one in which several unary operators (call them 3+( . ), 2*( . ), ( . )++ and ( . )[ i ]) are competing to bind to y. The order of precedence table resolves the final sub-expression they each act upon: ( . )[ i ] acts only on y, ( . )++ acts only on y[i], 2*( . ) acts only on y[i]++ and 3+( . ) acts 'only' on 2*((y[i])++). It is important to note that WHAT sub-expression gets acted on by each operator is clear from the precedence table but WHEN each operator acts is not resolved by the precedence table; in this example, the ( . )++ operator acts only on y[i] by the precedence rules but binding levels alone do not indicate the timing of the postfix ++ (the ( . )++ operator acts only after y[i] is evaluated in the expression).
The binding of operators in C and C++ is specified by a factored language grammar, rather than a precedence table. This creates some subtle conflicts. For example, in C, the syntax for a conditional expression is:
logical
-
OR
-
expression
?
expression
:
conditional
-
expression
while in C++ it is:
logical
-
OR
-
expression
?
expression
:
assignment
-
expression
Hence, the expression:
e = a < d ? a++ : a = d
is parsed differently in the two languages. In C, this expression is a syntax error, because the syntax for an assignment expression in C is:
unary
-
expression
'='
assignment
-
expression
In C++, it is parsed as:
e
=
(
a
<
d
?
a
++
:
(
a
=
d
))
which is a valid expression.
[
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.
[
13
]
[
14
]
For example,
int
a
=
1
,
b
=
2
,
weirdVariable
=
(
++
a
,
b
),
d
=
4
;
Criticism of bitwise and equality operators precedence
[
edit
]
The precedence of the bitwise logical operators has been criticized.
[
15
]
Conceptually, & and | are arithmetic operators like * and +.
The expression
a
&
b
==
7
is syntactically parsed as
a
&
(
b
==
7
)
whereas the expression
a
+
b
==
7
is parsed as
(
a
+
b
)
==
7
. This requires parentheses to be used more often than they otherwise would.
Historically, there was no syntactic distinction between the bitwise and logical operators. In
BCPL
,
B
and early C, the operators
&&
||
didn't exist. Instead
&
|
had different meaning depending on whether they are used in a 'truth-value context' (i.e. when a Boolean value was expected, for example in
if
(
a
==
b
&
c
)
{...}
it behaved as a logical operator, but in
c
=
a
&
b
it behaved as a bitwise one). It was retained so as to keep
backward compatibility
with existing installations.
[
16
]
Moreover, in C++ (and later versions of C) equality operations, with the exception of the three-way comparison operator, yield
bool
type values which are conceptually a single bit (1 or 0) and as such do not properly belong in "bitwise" operations.
^
The modulus operator only supports integer operands; for floating point, a function such as
fmod
can be used.
^
a
b
c
d
The
int
is a dummy parameter to differentiate between prefix and postfix.
^
About
C++20 three-way comparison
^
Possible return types:
std::weak_ordering
,
std::strong_ordering
and
std::partial_ordering
to which they all are convertible to.
^
a
b
In the context of
iostreams
in C++, writers often will refer to
<<
and
>>
as the "put-to" or "stream insertion" and "get-from" or "stream extraction" operators, respectively.
^
According to the C99 standard, the right shift of a negative number is implementation defined. Most implementations, e.g., the GCC,
[
3
]
use an
arithmetic shift
(i.e., sign extension), but a
logical shift
is possible.
^
According to the C99 standard, the right shift of a negative number is implementation defined. Most implementations, e.g., the GCC,
[
3
]
use an
arithmetic shift
(i.e., sign extension), but a
logical shift
is possible.
^
a
b
c
since C++23
^
The actual address of an object with an overloaded
operator &
can be obtained with
std::addressof
^
The return type of
operator
->
()
must be a type for which the
->
operation can be applied, such as a pointer type. If
x
is of type
C
where
C
overloads
operator
->
()
,
x
->
y
gets expanded to
x
.
operator
->
()
->
y
.
^
Meyers, Scott (October 1999),
"Implementing operator->* for Smart Pointers"
(PDF)
,
Dr. Dobb's Journal
, Aristeia
.
^
Although a
::
punctuator exists in C as of C23, it is not used as a scope resolution operator.
^
About
C++11 User-defined literals
^
a
b
c
d
e
f
g
since C++11
^
The parentheses are not necessary when taking the size of a value, only when taking the size of a type. However, they are usually used regardless.
[
citation needed
]
^
C++ defines
alignof
operator, whereas C defines
_Alignof
(C23 defines both). Both operators have the same semantics.
^
since C23; not in standard C++
^
Behaves like const_cast/static_cast/reinterpret_cast. In the last two cases, the
auto
specifier is replaced with the type of the invented variable x declared with
auto x(a);
(which is never interpreted as a function declaration) or
auto x{a};
, respectively.
^
For user-defined conversions, the return type implicitly and necessarily matches the operator name unless the type is inferred (e.g.
operator
auto
()
,
operator
decltype
(
auto
)()
etc.).
^
The type name can also be inferred (e.g
new auto
) if an initializer is provided.
^
The array size can also be inferred if an initializer is provided.
^
since C++26
Bitwise operations in C
– Operations transforming individual bits of integral data types
Bit manipulation
– Algorithmically modifying data below the word level
Logical operator
– Symbol connecting formulas in logic
Boolean algebra (logic)
– Algebraic manipulation of "true" and "false"
Table of logic symbols
– List of symbols used to express logical relations
^
"Operator overloading§Comparison operators"
.
cppreference.com
.
^
"Standard C++"
.
^
a
b
"Integers implementation",
GCC 4.3.3
, GNU
.
^
"ISO/IEC 9899:1999 specification, TC3"
(PDF)
. p. 64, § 6.4.6
Ponctuators
para. 3.
^
"user-defined conversion"
. Retrieved
5 April
2020
.
^
Explicit type conversion
in C++
^
ISO/IEC 14882:1998(E) Programming Language C++
. open-std.org – The C++ Standards Committee. 1 September 1998. pp.
40–
41.
^
ISO/IEC 9899:201x Programming Languages - C
. open-std.org – The C Standards Committee. 19 December 2011. p. 465.
^
the ISO C 1999 standard, section 6.5.6 note 71
(Technical report). ISO. 1999.
^
"C++ Built-in Operators, Precedence and Associativity"
.
docs.microsoft.com
. Retrieved
11 May
2020
.
^
"C Operator Precedence - cppreference.com"
.
en.cppreference.com
. Retrieved
10 April
2020
.
^
"Does the C/C++ ternary operator actually have the same precedence as assignment operators?"
.
Stack Overflow
. Retrieved
22 September
2019
.
^
"Other operators - cppreference.com"
.
en.cppreference.com
. Retrieved
10 April
2020
.
^
"c++ - How does the Comma Operator work"
.
Stack Overflow
. Retrieved
1 April
2020
.
^
C history § Neonatal C
, Bell labs
.
^
"Re^10: next unless condition"
.
www.perlmonks.org
. Retrieved
23 March
2018
.
"Operators",
C++ reference
(wiki)
.
C Operator Precedence
Postfix Increment and Decrement Operators: ++ and --
(Developer network), Microsoft, 17 August 2021
. |
| Markdown | [Jump to content](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#bodyContent)
Main menu
Main menu
move to sidebar
hide
Navigation
- [Main page](https://en.wikipedia.org/wiki/Main_Page "Visit the main page [z]")
- [Contents](https://en.wikipedia.org/wiki/Wikipedia:Contents "Guides to browsing Wikipedia")
- [Current events](https://en.wikipedia.org/wiki/Portal:Current_events "Articles related to current events")
- [Random article](https://en.wikipedia.org/wiki/Special:Random "Visit a randomly selected article [x]")
- [About Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:About "Learn about Wikipedia and how it works")
- [Contact us](https://en.wikipedia.org/wiki/Wikipedia:Contact_us "How to contact Wikipedia")
Contribute
- [Help](https://en.wikipedia.org/wiki/Help:Contents "Guidance on how to use and edit Wikipedia")
- [Learn to edit](https://en.wikipedia.org/wiki/Help:Introduction "Learn how to edit Wikipedia")
- [Community portal](https://en.wikipedia.org/wiki/Wikipedia:Community_portal "The hub for editors")
- [Recent changes](https://en.wikipedia.org/wiki/Special:RecentChanges "A list of recent changes to Wikipedia [r]")
- [Upload file](https://en.wikipedia.org/wiki/Wikipedia:File_upload_wizard "Add images or other media for use on Wikipedia")
- [Special pages](https://en.wikipedia.org/wiki/Special:SpecialPages "A list of all special pages [q]")
[  ](https://en.wikipedia.org/wiki/Main_Page)
[Search](https://en.wikipedia.org/wiki/Special:Search "Search Wikipedia [f]")
Appearance
- [Donate](https://donate.wikimedia.org/?wmf_source=donate&wmf_medium=sidebar&wmf_campaign=en.wikipedia.org&uselang=en)
- [Create account](https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&returnto=Operators+in+C+and+C%2B%2B "You are encouraged to create an account and log in; however, it is not mandatory")
- [Log in](https://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Operators+in+C+and+C%2B%2B "You're encouraged to log in; however, it's not mandatory. [o]")
Personal tools
- [Donate](https://donate.wikimedia.org/?wmf_source=donate&wmf_medium=sidebar&wmf_campaign=en.wikipedia.org&uselang=en)
- [Create account](https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&returnto=Operators+in+C+and+C%2B%2B "You are encouraged to create an account and log in; however, it is not mandatory")
- [Log in](https://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Operators+in+C+and+C%2B%2B "You're encouraged to log in; however, it's not mandatory. [o]")
## Contents
move to sidebar
hide
- [(Top)](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B)
- [1 Operators](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Operators)
Toggle Operators subsection
- [1\.1 Arithmetic](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Arithmetic)
- [1\.2 Relational](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Relational)
- [1\.3 Logical](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Logical)
- [1\.4 Bitwise](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Bitwise)
- [1\.5 Assignment](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Assignment)
- [1\.6 Member and pointer](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Member_and_pointer)
- [1\.7 Other](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Other)
- [1\.8 Synonyms](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Synonyms)
- [2 Expression evaluation order](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Expression_evaluation_order)
Toggle Expression evaluation order subsection
- [2\.1 Details](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Details)
- [2\.2 Chained expressions](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Chained_expressions)
- [2\.3 Binding](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Binding)
- [2\.4 Criticism of bitwise and equality operators precedence](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Criticism_of_bitwise_and_equality_operators_precedence)
- [3 Notes](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Notes)
- [4 See also](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#See_also)
- [5 References](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#References)
- [6 External links](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#External_links)
Toggle the table of contents
# Operators in C and C++
12 languages
- [Català](https://ca.wikipedia.org/wiki/Operadors_en_C_i_C%2B%2B "Operadors en C i C++ – Catalan")
- [Español](https://es.wikipedia.org/wiki/Anexo:Operadores_de_C_y_C%2B%2B "Anexo:Operadores de C y C++ – Spanish")
- [Magyar](https://hu.wikipedia.org/wiki/Oper%C3%A1torok_\(C%2B%2B\) "Operátorok (C++) – Hungarian")
- [Italiano](https://it.wikipedia.org/wiki/Operatori_in_C_e_C%2B%2B "Operatori in C e C++ – Italian")
- [日本語](https://ja.wikipedia.org/wiki/C%E3%81%A8C%2B%2B%E3%81%AE%E6%BC%94%E7%AE%97%E5%AD%90 "CとC++の演算子 – Japanese")
- [한국어](https://ko.wikipedia.org/wiki/C%EC%99%80_C%2B%2B%EC%9D%98_%EC%97%B0%EC%82%B0%EC%9E%90 "C와 C++의 연산자 – Korean")
- [Македонски](https://mk.wikipedia.org/wiki/%D0%9E%D0%BF%D0%B5%D1%80%D0%B0%D1%82%D0%BE%D1%80%D0%B8_%D0%B2%D0%BE_C_%D0%B8_C%2B%2B "Оператори во C и C++ – Macedonian")
- [Português](https://pt.wikipedia.org/wiki/Operadores_em_C_e_C%2B%2B "Operadores em C e C++ – Portuguese")
- [Русский](https://ru.wikipedia.org/wiki/%D0%9E%D0%BF%D0%B5%D1%80%D0%B0%D1%82%D0%BE%D1%80%D1%8B_%D0%B2_C_%D0%B8_C%2B%2B "Операторы в C и C++ – Russian")
- [Српски / srpski](https://sr.wikipedia.org/wiki/%D0%9E%D0%BF%D0%B5%D1%80%D0%B0%D1%82%D0%BE%D1%80%D0%B8_%D1%83_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D1%81%D0%BA%D0%B8%D0%BC_%D1%98%D0%B5%D0%B7%D0%B8%D1%86%D0%B8%D0%BC%D0%B0_C_%D0%B8_C%2B%2B "Оператори у програмским језицима C и C++ – Serbian")
- [Українська](https://uk.wikipedia.org/wiki/%D0%9E%D0%BF%D0%B5%D1%80%D0%B0%D1%82%D0%BE%D1%80%D0%B8_%D0%B2_C_%D1%82%D0%B0_C%2B%2B "Оператори в C та C++ – Ukrainian")
- [中文](https://zh.wikipedia.org/wiki/C%E5%92%8CC%2B%2B%E9%81%8B%E7%AE%97%E5%AD%90 "C和C++運算子 – Chinese")
[Edit links](https://www.wikidata.org/wiki/Special:EntityPage/Q1078424#sitelinks-wikipedia "Edit interlanguage links")
- [Article](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B "View the content page [c]")
- [Talk](https://en.wikipedia.org/wiki/Talk:Operators_in_C_and_C%2B%2B "Discuss improvements to the content page [t]")
English
- [Read](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B)
- [Edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit "Edit this page [e]")
- [View history](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=history "Past revisions of this page [h]")
Tools
Tools
move to sidebar
hide
Actions
- [Read](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B)
- [Edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit "Edit this page [e]")
- [View history](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=history)
General
- [What links here](https://en.wikipedia.org/wiki/Special:WhatLinksHere/Operators_in_C_and_C%2B%2B "List of all English Wikipedia pages containing links to this page [j]")
- [Related changes](https://en.wikipedia.org/wiki/Special:RecentChangesLinked/Operators_in_C_and_C%2B%2B "Recent changes in pages linked from this page [k]")
- [Upload file](https://en.wikipedia.org/wiki/Wikipedia:File_Upload_Wizard "Upload files [u]")
- [Permanent link](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&oldid=1337146407 "Permanent link to this revision of this page")
- [Page information](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=info "More information about this page")
- [Cite this page](https://en.wikipedia.org/w/index.php?title=Special:CiteThisPage&page=Operators_in_C_and_C%2B%2B&id=1337146407&wpFormIdentifier=titleform "Information on how to cite this page")
- [Get shortened URL](https://en.wikipedia.org/w/index.php?title=Special:UrlShortener&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FOperators_in_C_and_C%252B%252B)
Print/export
- [Download as PDF](https://en.wikipedia.org/w/index.php?title=Special:DownloadAsPdf&page=Operators_in_C_and_C%2B%2B&action=show-download-screen "Download this page as a PDF file")
- [Printable version](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&printable=yes "Printable version of this page [p]")
In other projects
- [Wikibooks](https://en.wikibooks.org/wiki/C_Programming/Operators_and_type_casting)
- [Wikidata item](https://www.wikidata.org/wiki/Special:EntityPage/Q1078424 "Structured data on this page hosted by Wikidata [g]")
Appearance
move to sidebar
hide
From Wikipedia, the free encyclopedia
This is a list of [operators](https://en.wikipedia.org/wiki/Operator_\(programming\) "Operator (programming)") in the [C](https://en.wikipedia.org/wiki/C_\(programming_language\) "C (programming language)") and [C++](https://en.wikipedia.org/wiki/C%2B%2B "C++") [programming languages](https://en.wikipedia.org/wiki/Programming_language "Programming language").
All listed operators are in C++ and lacking indication otherwise, in C as well. Some tables include a "In C" column that indicates whether an operator is also in C. Note that C does not support [operator overloading](https://en.wikipedia.org/wiki/Operator_overloading "Operator overloading").
When not overloaded, for the operators `&&`, `||`, and `,` (the [comma operator](https://en.wikipedia.org/wiki/Comma_operator "Comma operator")), there is a [sequence point](https://en.wikipedia.org/wiki/Sequence_point "Sequence point") after the evaluation of the first operand.
Most of the operators available in C and C++ are also available in other [C-family](https://en.wikipedia.org/wiki/C-family "C-family") languages such as [C\#](https://en.wikipedia.org/wiki/C_Sharp_\(programming_language\) "C Sharp (programming language)"), [D](https://en.wikipedia.org/wiki/D_\(programming_language\) "D (programming language)"), [Java](https://en.wikipedia.org/wiki/Java_\(programming_language\) "Java (programming language)"), [Perl](https://en.wikipedia.org/wiki/Perl "Perl"), and [PHP](https://en.wikipedia.org/wiki/PHP "PHP") with the same precedence, associativity, and semantics.
Many operators specified by a sequence of symbols are commonly referred to by a name that consists of the name of each symbol. For example, `+=` and `-=` are often called "plus equal(s)" and "minus equal(s)", instead of the more verbose "assignment by addition" and "assignment by subtraction".
## Operators
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=1 "Edit section: Operators")\]
In the following tables, lower case letters such as `a` and `b` represent literal values, object/variable names, or l-values, as appropriate. `R`, `S` and `T` stand for a data type, and `K` for a class or enumeration type. Some operators have alternative spellings using [digraphs and trigraphs](https://en.wikipedia.org/wiki/Digraphs_and_trigraphs_\(programming\) "Digraphs and trigraphs (programming)") or [operator synonyms](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Synonyms).
### Arithmetic
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=2 "Edit section: Arithmetic")\]
C and C++ have the same arithmetic operators and all can be overloaded in C++.
| Operation | Syntax | C++ prototype | |
|---|---|---|---|
| in class K | outside class | | |
| [Addition](https://en.wikipedia.org/wiki/Addition "Addition") | `a + b` | `R K::operator +(S b);` | `R operator +(K a, S b);` |
| [Subtraction](https://en.wikipedia.org/wiki/Subtraction "Subtraction") | `a - b` | `R K::operator -(S b);` | `R operator -(K a, S b);` |
| [Unary](https://en.wikipedia.org/wiki/Unary_operation "Unary operation") plus; [integer promotion](https://en.wikipedia.org/wiki/Type_conversion#Type_promotion "Type conversion") | `+a` | `R K::operator +();` | `R operator +(K a);` |
| [Unary](https://en.wikipedia.org/wiki/Unary_operation "Unary operation") minus; [additive inverse](https://en.wikipedia.org/wiki/Additive_inverse "Additive inverse") | `-a` | `R K::operator -();` | `R operator -(K a);` |
| [Multiplication](https://en.wikipedia.org/wiki/Multiplication "Multiplication") | `a * b` | `R K::operator *(S b);` | `R operator *(K a, S b);` |
| [Division](https://en.wikipedia.org/wiki/Division_\(mathematics\) "Division (mathematics)") | `a / b` | `R K::operator /(S b);` | `R operator /(K a, S b);` |
| [Modulo](https://en.wikipedia.org/wiki/Modulo_operation "Modulo operation")[\[a\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-modulo-1) | `a % b` | `R K::operator %(S b);` | `R operator %(K a, S b);` |
| Prefix [increment](https://en.wikipedia.org/wiki/Increment_and_decrement_operators "Increment and decrement operators") | `++a` | `R& K::operator ++();` | `R& operator ++(K& a);` |
| Postfix increment | `a++` | `R K::operator ++(int);`[\[b\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-dummy-int-2) | `R operator ++(K& a, int);`[\[b\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-dummy-int-2) |
| Prefix [decrement](https://en.wikipedia.org/wiki/Increment_and_decrement_operators "Increment and decrement operators") | `--a` | `R& K::operator --();` | `R& operator --(K& a);` |
| Postfix decrement | `a--` | `R K::operator --(int);`[\[b\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-dummy-int-2) | `R operator --(K& a, int);`[\[b\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-dummy-int-2) |
### Relational
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=3 "Edit section: Relational")\]
All [relational](https://en.wikipedia.org/wiki/Relational_operator "Relational operator") (comparison) operators can be overloaded in C++. Since [C++20](https://en.wikipedia.org/wiki/C%2B%2B20 "C++20"), the inequality operator is automatically generated if `operator==` is defined and all four relational operators are automatically generated if `operator<=>` is defined.[\[1\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-3)
| Operation | Syntax | In C | C++ prototype | |
|---|---|---|---|---|
| in class K | outside class | | | |
| Equal to | `a == b` | Yes | `bool K::operator ==(S const& b) const;` | `bool operator ==(K const& a, S const& b);` |
| Not equal to | `a != b` | Yes | `bool K::operator !=(S const& b) const;` | `bool operator !=(K const& a, S const& b);` |
| Greater than | `a > b` | Yes | `bool K::operator >(S const& b) const;` | `bool operator >(K const& a, S const& b);` |
| Less than | `a < b` | Yes | `bool K::operator <(S const& b) const;` | `bool operator <(K const& a, S const& b);` |
| Greater than or equal to | `a >= b` | Yes | `bool K::operator >=(S const& b) const;` | `bool operator >=(K const& a, S const& b);` |
| Less than or equal to | `a <= b` | Yes | `bool K::operator <=(S const& b) const;` | `bool operator <=(K const& a, S const& b);` |
| [Three-way comparison](https://en.wikipedia.org/wiki/Three-way_comparison "Three-way comparison")[\[c\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-threewaycomparison-4)[\[d\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-5) | `a <=> b` | No | `auto K::operator <=>(const S &b);` | `auto operator <=>(const K &a, const S &b);` |
### Logical
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=4 "Edit section: Logical")\]
C and C++ have the same logical operators and all can be overloaded in C++.
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](https://en.wikipedia.org/wiki/Short-circuit_evaluation "Short-circuit evaluation").[\[2\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-6)
| Operation | Syntax | C++ prototype | |
|---|---|---|---|
| in class K | outside class | | |
| [NOT](https://en.wikipedia.org/wiki/Negation "Negation") | `!a` | `bool K::operator !();` | `bool operator !(K a);` |
| [AND](https://en.wikipedia.org/wiki/Logical_conjunction "Logical conjunction") | `a && b` | `bool K::operator &&(S b);` | `bool operator &&(K a, S b);` |
| [OR](https://en.wikipedia.org/wiki/Logical_disjunction "Logical disjunction") | `a || b` | `bool K::operator ||(S b);` | `bool operator ||(K a, S b);` |
### Bitwise
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=5 "Edit section: Bitwise")\]
C and C++ have the same bitwise operators and all can be overloaded in C++.
| Operation | Syntax | C++ prototype | |
|---|---|---|---|
| in class K | outside class | | |
| [NOT](https://en.wikipedia.org/wiki/Bitwise_operation#NOT "Bitwise operation") | `~a` | `R K::operator ~();` | `R operator ~(K a);` |
| [AND](https://en.wikipedia.org/wiki/Bitwise_operation#AND "Bitwise operation") | `a & b` | `R K::operator &(S b);` | `R operator &(K a, S b);` |
| [OR](https://en.wikipedia.org/wiki/Bitwise_operation#OR "Bitwise operation") | `a | b` | `R K::operator |(S b);` | `R operator |(K a, S b);` |
| [XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR "Bitwise operation") | `a ^ b` | `R K::operator ^(S b);` | `R operator ^(K a, S b);` |
| [Shift](https://en.wikipedia.org/wiki/Bitwise_shift "Bitwise shift") left[\[e\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-bitshift-7) | `a << b` | `R K::operator <<(S b);` | `R operator <<(K a, S b);` |
| Shift right[\[e\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-bitshift-7)[\[f\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-9) | `a >> b` | `R K::operator >>(S b);` | `R operator >>(K a, S b);` |
### Assignment
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=6 "Edit section: Assignment")\]
C and C++ have the same assignment operators and all can be overloaded in C++.
For the combination operators, `a ⊚= b` (where `⊚` represents an operation) is equivalent to `a = a ⊚ b`, except that `a` is evaluated only once.
| Operation | Syntax | C++ prototype | |
|---|---|---|---|
| in class K | outside class | | |
| [Assignment](https://en.wikipedia.org/wiki/Assignment_operator_\(C%2B%2B\) "Assignment operator (C++)") | `a = b` | `R& K::operator =(S b);` | —N/a |
| Addition combination | `a += b` | `R& K::operator +=(S b);` | `R& operator +=(K& a, S b);` |
| Subtraction combination | `a -= b` | `R& K::operator -=(S b);` | `R& operator -=(K& a, S b);` |
| Multiplication combination | `a *= b` | `R& K::operator *=(S b);` | `R& operator *=(K& a, S b);` |
| Division combination | `a /= b` | `R& K::operator /=(S b);` | `R& operator /=(K& a, S b);` |
| Modulo combination | `a %= b` | `R& K::operator %=(S b);` | `R& operator %=(K& a, S b);` |
| Bitwise AND combination | `a &= b` | `R& K::operator &=(S b);` | `R& operator &=(K& a, S b);` |
| Bitwise OR combination | `a |= b` | `R& K::operator |=(S b);` | `R& operator |=(K& a, S b);` |
| Bitwise XOR combination | `a ^= b` | `R& K::operator ^=(S b);` | `R& operator ^=(K& a, S b);` |
| Bitwise left shift combination | `a <<= b` | `R& K::operator <<=(S b);` | `R& operator <<=(K& a, S b);` |
| Bitwise right shift combination[\[g\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-rightbitshift-10) | `a >>= b` | `R& K::operator >>=(S b);` | `R& operator >>=(K& a, S b);` |
### Member and pointer
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=7 "Edit section: Member and pointer")\]
| Operation | Syntax | Can overload | In C | C++ prototype | |
|---|---|---|---|---|---|
| in class K | outside class | | | | |
| [Subscript](https://en.wikipedia.org/wiki/Indexer_\(programming\) "Indexer (programming)") | `a[b]``a<:b:>`[\[4\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-11) | Yes | Yes | `R& K::operator [](S b);` `R& K::operator [](S b, ...);`[\[h\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX23-12) | —N/a |
| Indirection (object pointed to by *a*) | `*a` | Yes | Yes | `R& K::operator *();` | `R& operator *(K a);` |
| Address-of (address of *a*) | `&a` | Yes[\[i\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-addressof2-13) | Yes | `R* K::operator &();` | `R* operator &(K a);` |
| Structure dereference (member *b* of object pointed to by *a*) | `a->b` | Yes | Yes | `R* K::operator ->();`[\[j\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-arrowptr-14) | —N/a |
| Structure reference (member *b* of object *a*) | `a.b` | No | Yes | —N/a | |
| Member selected by [pointer-to-member](https://en.wikipedia.org/wiki/Pointer-to-member "Pointer-to-member") *b* of object pointed to by *a*[\[k\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-arrowstar-15) | `a->*b` | Yes | No | `R& K::operator ->*(S b);` | `R& operator ->*(K a, S b);` |
| Member of object *a* selected by [pointer-to-member](https://en.wikipedia.org/wiki/Pointer-to-member "Pointer-to-member") *b* | `a.*b` | No | No | —N/a | |
### Other
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=8 "Edit section: Other")\]
| Operation | Syntax | Can overload | In C | C++ prototype | |
|---|---|---|---|---|---|
| in class K | outside class | | | | |
| [Function](https://en.wikipedia.org/wiki/Function_\(programming\) "Function (programming)") call | `a(a1, a2)` | Yes | Yes | `R K::operator ()(S a, T b, ...);` | —N/a |
| [Comma](https://en.wikipedia.org/wiki/Comma_operator "Comma operator") | `a, b` | Yes | Yes | `R K::operator ,(S b);` | `R operator ,(K a, S b);` |
| [Ternary conditional](https://en.wikipedia.org/wiki/%3F: "?:") | `a ? b : c` | No | Yes | —N/a | |
| [Scope resolution](https://en.wikipedia.org/wiki/Scope_resolution_operator#C++ "Scope resolution operator") | `a::b`[\[l\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-scopal-16) | No | No | —N/a | |
| User-defined literals[\[m\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-ud-literal-17)[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) | `"a"_b` | Yes | No | —N/a | `R operator "" _b(T a)` |
| [Sizeof](https://en.wikipedia.org/wiki/Sizeof "Sizeof") | `sizeof a`[\[o\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sizeof-19) `sizeof (R)` | No | Yes | —N/a | |
| Size of [parameter pack](https://en.wikipedia.org/wiki/Variadic_template "Variadic template")[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) | `sizeof...(Args)` | No | No | —N/a | |
| Alignof[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) | `alignof(R)` or `_Alignof(R)`[\[p\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-alignof-20) | No | Yes | —N/a | |
| [Typeof](https://en.wikipedia.org/wiki/Typeof "Typeof")[\[q\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-typeof-21) | `typeof(a)` `typeof(R)` `typeof_unqual(a)` `typeof_unqual(R)` | —N/a | Yes | —N/a | |
| [Decltype](https://en.wikipedia.org/wiki/Decltype "Decltype")[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) | `decltype(a)` `decltype(R)` | No | No | —N/a | |
| Type identification | `typeid(a)` `typeid(R)` | No | No | —N/a | |
| [Conversion](https://en.wikipedia.org/wiki/Type_conversion "Type conversion") (C-style cast) | `(R)a` | Yes | Yes | `K::operator R();`[\[5\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-22) | —N/a |
| [Conversion](https://en.wikipedia.org/wiki/Type_conversion "Type conversion")[\[r\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-23)[\[6\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-24) | `R(a)` `R{a}`[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) `auto(a)`[\[h\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX23-12) `auto{a}`[\[h\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX23-12) | No | No | —N/a | |
| [static\_cast](https://en.wikipedia.org/wiki/Static_cast "Static cast") conversion[\[s\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-25) | `static_cast<R>(a)` | Yes | No | `K::operator R();` `explicit K::operator R();`[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) | —N/a |
| [dynamic cast](https://en.wikipedia.org/wiki/Dynamic_cast "Dynamic cast") conversion | `dynamic_cast<R>(a)` | No | No | —N/a | |
| [const\_cast](https://en.wikipedia.org/wiki/Const_cast "Const cast") conversion | `const_cast<R>(a)` | No | No | —N/a | |
| [reinterpret\_cast](https://en.wikipedia.org/wiki/Reinterpret_cast "Reinterpret cast") conversion | `reinterpret_cast<R>(a)` | No | No | —N/a | |
| [Allocate memory](https://en.wikipedia.org/wiki/New_\(c%2B%2B\) "New (c++)") | `new R`[\[t\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-infer-26) | Yes | No | `void* K::operator new(size_t x);` | `void* operator new(size_t x);` |
| Allocate array | `new R[n]`[\[u\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-infer2-27) | Yes | No | `void* K::operator new[](size_t a);` | `void* operator new[](size_t a);` |
| [Deallocate memory](https://en.wikipedia.org/wiki/Operator_delete "Operator delete") | `delete a` | Yes | No | `void K::operator delete(void* a);` | `void operator delete(void* a);` |
| Deallocate array | `delete[] a` | Yes | No | `void K::operator delete[](void* a);` | `void operator delete[](void* a);` |
| Exception check[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) | `noexcept(a)` | No | No | —N/a | |
| [Reflection](https://en.wikipedia.org/wiki/Reflective_programming "Reflective programming")[\[v\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX26-28) | `^^a` | No | No | —N/a | |
### Synonyms
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=9 "Edit section: Synonyms")\]
C++ defines keywords to act as aliases for a number of operators:[\[7\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-Committee-29)
| Keyword | Operator |
|---|---|
| `and` | `&&` |
| `and_eq` | `&=` |
| `bitand` | `&` |
| `bitor` | `|` |
| `compl` | `~` |
| `not` | `!` |
| `not_eq` | `!=` |
| `or` | `||` |
| `or_eq` | `|=` |
| `xor` | `^` |
| `xor_eq` | `^=` |
Each keyword is a different way to specify an operator and as such can be used instead of the corresponding symbolic variation. For example, `(a > 0 and not flag)` and `(a > 0 && !flag)` specify the same behavior. As another example, the `bitand` keyword may be used to replace not only the *bitwise-and* operator but also the *address-of* operator, and it can be used to specify reference types (e.g., `int bitand ref = n`).
The ISO C specification makes allowance for these keywords as preprocessor macros in the header file [`iso646.h`](https://en.wikipedia.org/wiki/Iso646.h "Iso646.h"). For compatibility with C, C++ also provides the header `iso646.h`, the inclusion of which has no effect. Until C++20, it also provided the corresponding header [`ciso646`](https://en.wikipedia.org/wiki/Ciso646 "Ciso646") which had no effect as well.
## Expression evaluation order
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=10 "Edit section: Expression evaluation order")\]
During expression evaluation, the order in which sub-expressions are evaluated is determined by [precedence](https://en.wikipedia.org/wiki/Order_of_operations "Order of operations") and [associativity](https://en.wikipedia.org/wiki/Operator_associativity "Operator associativity"). An operator with higher precedence is evaluated before a operator of lower precedence and the operands of an operator are evaluated based on associativity. The following table describes the precedence and associativity of the C and C++ operators. Operators are shown in groups of equal precedence with groups ordered in descending precedence from top to bottom (lower order is higher precedence).[\[8\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-30)[\[9\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-31)[\[10\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-32)
Operator precedence is not affected by overloading.
| Order | Operator | Description | Associativity |
|---|---|---|---|
| 1 highest | `::` | [Scope resolution](https://en.wikipedia.org/wiki/Scope_resolution_operator#C.2B.2B "Scope resolution operator") (C++ only) | None |
| 2 | `++` | Postfix increment | Left-to-right |
| `--` | Postfix decrement | | |
| `()` | Function call | | |
| `[]` | Array subscripting | | |
| `.` | Element selection by reference | | |
| `->` | Element selection through pointer | | |
| `typeid()` | [Run-time type information](https://en.wikipedia.org/wiki/Run-time_type_information "Run-time type information") (C++ only) (see [typeid](https://en.wikipedia.org/wiki/Typeid "Typeid")) | | |
| `const_cast` | Type cast (C++ only) (see [const\_cast](https://en.wikipedia.org/wiki/Const_cast "Const cast")) | | |
| `dynamic_cast` | Type cast (C++ only) (see [dynamic cast](https://en.wikipedia.org/wiki/Dynamic_cast "Dynamic cast")) | | |
| `reinterpret_cast` | Type cast (C++ only) (see [reinterpret\_cast](https://en.wikipedia.org/wiki/Reinterpret_cast "Reinterpret cast")) | | |
| `static_cast` | Type cast (C++ only) (see [static\_cast](https://en.wikipedia.org/wiki/Static_cast "Static cast")) | | |
| 3 | `++` | Prefix increment | Right-to-left |
| `--` | Prefix decrement | | |
| `+` | Unary plus | | |
| `-` | Unary minus | | |
| `!` | Logical NOT | | |
| `~` | Bitwise NOT ([ones' complement](https://en.wikipedia.org/wiki/Ones%27_complement "Ones' complement")) | | |
| `(type)` | Type cast | | |
| `*` | Indirection (dereference) | | |
| `&` | Address-of | | |
| `sizeof` | [Sizeof](https://en.wikipedia.org/wiki/Sizeof "Sizeof") | | |
| `_Alignof` | Alignment requirement (since C11) | | |
| `new`, `new[]` | Dynamic memory allocation (C++ only) | | |
| `delete`, `delete[]` | Dynamic memory deallocation (C++ only) | | |
| 4 | `.*` | Pointer to member (C++ only) | Left-to-right |
| `->*` | Pointer to member (C++ only) | | |
| 5 | `*` | Multiplication | Left-to-right |
| `/` | Division | | |
| `%` | [Modulo](https://en.wikipedia.org/wiki/Modulo_operation "Modulo operation") (remainder) | | |
| 6 | `+` | Addition | Left-to-right |
| `-` | Subtraction | | |
| 7 | `<<` | [Bitwise](https://en.wikipedia.org/wiki/Bitwise_operation "Bitwise operation") left shift | Left-to-right |
| `>>` | [Bitwise](https://en.wikipedia.org/wiki/Bitwise_operation "Bitwise operation") right shift | | |
| 8 | `<=>` | [Three-way comparison](https://en.wikipedia.org/wiki/Three-way_comparison "Three-way comparison") (Introduced in [C++20](https://en.wikipedia.org/wiki/C%2B%2B20 "C++20") - C++ only) | Left-to-right |
| 9 | `<` | Less than | Left-to-right |
| `<=` | Less than or equal to | | |
| `>` | Greater than | | |
| `>=` | Greater than or equal to | | |
| 10 | `==` | Equal to | Left-to-right |
| `!=` | Not equal to | | |
| 11 | `&` | Bitwise AND | Left-to-right |
| 12 | `^` | Bitwise XOR (exclusive or) | Left-to-right |
| 13 | `|` | Bitwise OR (inclusive or) | Left-to-right |
| 14 | `&&` | Logical AND | Left-to-right |
| 15 | `||` | Logical OR | Left-to-right |
| 16 | `co_await` | Coroutine processing (C++ only) | Right-to-left |
| `co_yield` | | | |
| 17 | `?:` | [Ternary conditional operator](https://en.wikipedia.org/wiki/Ternary_conditional_operator "Ternary conditional operator") | Right-to-left |
| `=` | Direct assignment | | |
| `+=` | Assignment by sum | | |
| `-=` | Assignment by difference | | |
| `*=` | Assignment by product | | |
| `/=` | Assignment by quotient | | |
| `%=` | Assignment by remainder | | |
| `<<=` | Assignment by bitwise left shift | | |
| `>>=` | Assignment by bitwise right shift | | |
| `&=` | Assignment by bitwise AND | | |
| `^=` | Assignment by bitwise XOR | | |
| `|=` | Assignment by bitwise OR | | |
| `throw` | Throw operator (exceptions throwing, C++ only) | | |
| 18 lowest | `,` | [Comma](https://en.wikipedia.org/wiki/Comma_operator "Comma operator") | Left-to-right |
### Details
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=11 "Edit section: Details")\]
Although this table is adequate for describing most evaluation order, it does not describe a few details. The [ternary operator](https://en.wikipedia.org/wiki/Ternary_operator "Ternary operator") allows any arbitrary expression as its middle operand, despite being listed as having higher precedence than the assignment and comma operators. Thus `a ? b, c : d` is interpreted as `a ? (b, c) : d`, and not as the meaningless `(a ? b), (c : d)`. So, the expression in the middle of the conditional operator (between `?` and `:`) is parsed as if parenthesized. Also, the immediate, un-parenthesized result of a C cast expression cannot be the operand of `sizeof`. Therefore, `sizeof (int) * x` is interpreted as `(sizeof(int)) * x` and not `sizeof ((int) * x)`.
### Chained expressions
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=12 "Edit section: Chained expressions")\]
The precedence table determines the order of binding in chained expressions, when it is not expressly specified by parentheses.
- For example, `++x*3` is ambiguous without some precedence rule(s). The precedence table tells us that: `x` is 'bound' more tightly to
`++` than to
`*`, so that whatever
`++` does (now or later—see below), it does it ONLY to
`x` (and not to `x*3`); it is equivalent to (`++x`, `x*3`).
- Similarly, with `3*x++`, where though the post-fix
`++` is designed to act AFTER the entire expression is evaluated, the precedence table makes it clear that ONLY
`x` gets incremented (and NOT `3*x`). In fact, the expression (`tmp=x++`, `3*tmp`) is evaluated with
`tmp` being a temporary value. It is functionally equivalent to something like (`tmp=3*x`, `++x`, `tmp`).
[](https://en.wikipedia.org/wiki/File:Precedence_2.png)
Precedence and bindings
- Abstracting the issue of precedence or binding, consider the diagram above for the expression 3+2\*y\[i\]++. The compiler's job is to resolve the diagram into an expression, one in which several unary operators (call them 3+( . ), 2\*( . ), ( . )++ and ( . )\[ i \]) are competing to bind to y. The order of precedence table resolves the final sub-expression they each act upon: ( . )\[ i \] acts only on y, ( . )++ acts only on y\[i\], 2\*( . ) acts only on y\[i\]++ and 3+( . ) acts 'only' on 2\*((y\[i\])++). It is important to note that WHAT sub-expression gets acted on by each operator is clear from the precedence table but WHEN each operator acts is not resolved by the precedence table; in this example, the ( . )++ operator acts only on y\[i\] by the precedence rules but binding levels alone do not indicate the timing of the postfix ++ (the ( . )++ operator acts only after y\[i\] is evaluated in the expression).
### Binding
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=13 "Edit section: Binding")\]
The binding of operators in C and C++ is specified by a factored language grammar, rather than a precedence table. This creates some subtle conflicts. For example, in C, the syntax for a conditional expression is:
```
logical-OR-expression ? expression : conditional-expression
```
while in C++ it is:
```
logical-OR-expression ? expression : assignment-expression
```
Hence, the expression:
```
e = a < d ? a++ : a = d
```
is parsed differently in the two languages. In C, this expression is a syntax error, because the syntax for an assignment expression in C is:
```
unary-expression '=' assignment-expression
```
In C++, it is parsed as:
```
e = (a < d ? a++ : (a = d))
```
which is a valid expression.[\[11\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-33)[\[12\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-34)
To use the comma operator in a function call argument expression, variable assignment, or a comma-separated list, use of parentheses is required.[\[13\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-35)[\[14\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-36) For example,
```
int a = 1, b = 2, weirdVariable = (++a, b), d = 4;
```
### Criticism of bitwise and equality operators precedence
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=14 "Edit section: Criticism of bitwise and equality operators precedence")\]
The precedence of the bitwise logical operators has been criticized.[\[15\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-Bell-37) Conceptually, & and \| are arithmetic operators like \* and +.
The expression `a & b == 7` is syntactically parsed as `a & (b == 7)` whereas the expression `a + b == 7` is parsed as `(a + b) == 7`. This requires parentheses to be used more often than they otherwise would.
Historically, there was no syntactic distinction between the bitwise and logical operators. In [BCPL](https://en.wikipedia.org/wiki/BCPL "BCPL"), [B](https://en.wikipedia.org/wiki/B_\(programming_language\) "B (programming language)") and early C, the operators `&& ||` didn't exist. Instead `& |` had different meaning depending on whether they are used in a 'truth-value context' (i.e. when a Boolean value was expected, for example in `if (a==b & c) {...}` it behaved as a logical operator, but in `c = a & b` it behaved as a bitwise one). It was retained so as to keep [backward compatibility](https://en.wikipedia.org/wiki/Backward_compatibility "Backward compatibility") with existing installations.[\[16\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-38)
Moreover, in C++ (and later versions of C) equality operations, with the exception of the three-way comparison operator, yield [bool](https://en.wikipedia.org/wiki/Boolean_data_type "Boolean data type") type values which are conceptually a single bit (1 or 0) and as such do not properly belong in "bitwise" operations.
## Notes
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=15 "Edit section: Notes")\]
1. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-modulo_1-0)** The modulus operator only supports integer operands; for floating point, a function such as [`fmod`](https://en.wikipedia.org/wiki/Math.h "Math.h") can be used.
2. ^ [***a***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-dummy-int_2-0) [***b***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-dummy-int_2-1) [***c***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-dummy-int_2-2) [***d***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-dummy-int_2-3) The `int` is a dummy parameter to differentiate between prefix and postfix.
3. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-threewaycomparison_4-0)** About [C++20 three-way comparison](https://en.cppreference.com/w/cpp/language/operator_comparison#Three-way_comparison)
4. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-5)** Possible return types: `std::weak_ordering`, `std::strong_ordering` and `std::partial_ordering` to which they all are convertible to.
5. ^ [***a***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-bitshift_7-0) [***b***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-bitshift_7-1) In the context of [iostreams](https://en.wikipedia.org/wiki/Iostream "Iostream") in C++, writers often will refer to `<<` and `>>` as the "put-to" or "stream insertion" and "get-from" or "stream extraction" operators, respectively.
6. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-9)** According to the C99 standard, the right shift of a negative number is implementation defined. Most implementations, e.g., the GCC,[\[3\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-Integers-8) use an [arithmetic shift](https://en.wikipedia.org/wiki/Arithmetic_shift "Arithmetic shift") (i.e., sign extension), but a [logical shift](https://en.wikipedia.org/wiki/Logical_shift "Logical shift") is possible.
7. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-rightbitshift_10-0)** According to the C99 standard, the right shift of a negative number is implementation defined. Most implementations, e.g., the GCC,[\[3\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-Integers-8) use an [arithmetic shift](https://en.wikipedia.org/wiki/Arithmetic_shift "Arithmetic shift") (i.e., sign extension), but a [logical shift](https://en.wikipedia.org/wiki/Logical_shift "Logical shift") is possible.
8. ^ [***a***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX23_12-0) [***b***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX23_12-1) [***c***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX23_12-2) since C++23
9. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-addressof2_13-0)** The actual address of an object with an overloaded `operator &` can be obtained with [`std::addressof`](https://en.cppreference.com/w/cpp/memory/addressof)
10. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-arrowptr_14-0)** The return type of `operator->()` must be a type for which the `->` operation can be applied, such as a pointer type. If `x` is of type `C` where `C` overloads `operator->()`, `x->y` gets expanded to `x.operator->()->y`.
11. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-arrowstar_15-0)**
Meyers, Scott (October 1999), ["Implementing operator-\>\* for Smart Pointers"](http://aristeia.com/Papers/DDJ_Oct_1999.pdf) (PDF), *Dr. Dobb's Journal*, Aristeia
.
12. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-scopal_16-0)** Although a `::` punctuator exists in C as of C23, it is not used as a scope resolution operator.
13. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-ud-literal_17-0)** About [C++11 User-defined literals](http://en.cppreference.com/w/cpp/language/user_literal)
14. ^ [***a***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-0) [***b***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-1) [***c***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-2) [***d***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-3) [***e***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-4) [***f***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-5) [***g***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-6) since C++11
15. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sizeof_19-0)** The parentheses are not necessary when taking the size of a value, only when taking the size of a type. However, they are usually used regardless.\[*[citation needed](https://en.wikipedia.org/wiki/Wikipedia:Citation_needed "Wikipedia:Citation needed")*\]
16. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-alignof_20-0)** C++ defines `alignof` operator, whereas C defines `_Alignof` (C23 defines both). Both operators have the same semantics.
17. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-typeof_21-0)** since C23; not in standard C++
18. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-23)** Behaves like const\_cast/static\_cast/reinterpret\_cast. In the last two cases, the `auto` specifier is replaced with the type of the invented variable x declared with `auto x(a);` (which is never interpreted as a function declaration) or `auto x{a};`, respectively.
19. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-25)** For user-defined conversions, the return type implicitly and necessarily matches the operator name unless the type is inferred (e.g. `operator auto()`, `operator decltype(auto)()` etc.).
20. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-infer_26-0)** The type name can also be inferred (e.g `new auto`) if an initializer is provided.
21. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-infer2_27-0)** The array size can also be inferred if an initializer is provided.
22. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX26_28-0)** since C++26
## See also
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=16 "Edit section: See also")\]
- [Bitwise operations in C](https://en.wikipedia.org/wiki/Bitwise_operations_in_C "Bitwise operations in C") – Operations transforming individual bits of integral data types
- [Bit manipulation](https://en.wikipedia.org/wiki/Bit_manipulation "Bit manipulation") – Algorithmically modifying data below the word level
- [Logical operator](https://en.wikipedia.org/wiki/Logical_operator "Logical operator") – Symbol connecting formulas in logicPages displaying short descriptions of redirect targets
- [Boolean algebra (logic)](https://en.wikipedia.org/wiki/Boolean_algebra_\(logic\) "Boolean algebra (logic)") – Algebraic manipulation of "true" and "false"Pages displaying short descriptions of redirect targets
- [Table of logic symbols](https://en.wikipedia.org/wiki/Table_of_logic_symbols "Table of logic symbols") – List of symbols used to express logical relationsPages displaying short descriptions of redirect targets
## References
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=17 "Edit section: References")\]
1. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-3)**
["Operator overloading§Comparison operators"](https://en.cppreference.com/w/cpp/language/operators#Comparison_operators). *cppreference.com*.
2. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-6)**
["Standard C++"](https://isocpp.org/wiki/faq/operator-overloading).
3. ^ [***a***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-Integers_8-0) [***b***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-Integers_8-1)
"Integers implementation", [*GCC 4.3.3*](https://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Integers-implementation.html#Integers-implementation), GNU
.
4. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-11)**
["ISO/IEC 9899:1999 specification, TC3"](https://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf#%5B%7B%22num%22%3A148%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C-27%2C816%2Cnull%5D) (PDF). p. 64, § 6.4.6 *Ponctuators* para. 3.
5. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-22)**
["user-defined conversion"](https://en.cppreference.com/w/cpp/language/cast_operator). Retrieved 5 April 2020.
6. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-24)** [Explicit type conversion](https://en.cppreference.com/w/cpp/language/explicit_cast) in C++
7. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-Committee_29-0)**
*ISO/IEC 14882:1998(E) Programming Language C++*. open-std.org – The C++ Standards Committee. 1 September 1998. pp. 40–41\.
8. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-30)**
*ISO/IEC 9899:201x Programming Languages - C*. open-std.org – The C Standards Committee. 19 December 2011. p. 465.
9. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-31)**
*the ISO C 1999 standard, section 6.5.6 note 71* (Technical report). ISO. 1999.
10. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-32)**
["C++ Built-in Operators, Precedence and Associativity"](https://docs.microsoft.com/en-US/cpp/cpp/cpp-built-in-operators-precedence-and-associativity). *docs.microsoft.com*. Retrieved 11 May 2020.
11. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-33)**
["C Operator Precedence - cppreference.com"](https://en.cppreference.com/w/c/language/operator_precedence). *en.cppreference.com*. Retrieved 10 April 2020.
12. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-34)**
["Does the C/C++ ternary operator actually have the same precedence as assignment operators?"](https://stackoverflow.com/questions/13515434/does-the-c-c-ternary-operator-actually-have-the-same-precedence-as-assignment/13515505). *Stack Overflow*. Retrieved 22 September 2019.
13. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-35)**
["Other operators - cppreference.com"](https://en.cppreference.com/w/c/language/operator_other). *en.cppreference.com*. Retrieved 10 April 2020.
14. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-36)**
["c++ - How does the Comma Operator work"](https://stackoverflow.com/questions/54142/how-does-the-comma-operator-work/). *Stack Overflow*. Retrieved 1 April 2020.
15. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-Bell_37-0)**
[*C history § Neonatal C*](https://www.bell-labs.com/usr/dmr/www/chist.html), Bell labs
.
16. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-38)**
["Re^10: next unless condition"](https://www.perlmonks.org/?node_id=1159769). *www.perlmonks.org*. Retrieved 23 March 2018.
## External links
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=18 "Edit section: External links")\]
- "Operators", [*C++ reference*](https://en.cppreference.com/w/cpp/language/expressions#Operators) (wiki)
.
- [C Operator Precedence](https://en.cppreference.com/w/c/language/operator_precedence)
- [*Postfix Increment and Decrement Operators: ++ and --*](https://docs.microsoft.com/en-US/cpp/cpp/postfix-increment-and-decrement-operators-increment-and-decrement) (Developer network), Microsoft, 17 August 2021
.
| [v](https://en.wikipedia.org/wiki/Template:C_programming_language "Template:C programming language") [t](https://en.wikipedia.org/wiki/Template_talk:C_programming_language "Template talk:C programming language") [e](https://en.wikipedia.org/wiki/Special:EditPage/Template:C_programming_language "Special:EditPage/Template:C programming language")[C programming language](https://en.wikipedia.org/wiki/C_\(programming_language\) "C (programming language)") | |
|---|---|
| [ANSI C](https://en.wikipedia.org/wiki/ANSI_C "ANSI C") [C99](https://en.wikipedia.org/wiki/C99 "C99") [C11](https://en.wikipedia.org/wiki/C11_\(C_standard_revision\) "C11 (C standard revision)") [C17](https://en.wikipedia.org/wiki/C17_\(C_standard_revision\) "C17 (C standard revision)") [C23](https://en.wikipedia.org/wiki/C23_\(C_standard_revision\) "C23 (C standard revision)") [C2Y](https://en.wikipedia.org/wiki/C2Y_\(C_standard_revision\) "C2Y (C standard revision)") [Embedded C](https://en.wikipedia.org/wiki/Embedded_C "Embedded C") [MISRA C](https://en.wikipedia.org/wiki/MISRA_C "MISRA C") | |
| Features | [Freestanding implementation](https://en.wikipedia.org/wiki/Freestanding_\(C%2B%2B_implementation\) "Freestanding (C++ implementation)") [Functions](https://en.wikipedia.org/wiki/Subroutine "Subroutine") [Header files](https://en.wikipedia.org/wiki/Include_directive#C "Include directive") [Operators]() [String](https://en.wikipedia.org/wiki/C_string_handling "C string handling") [Syntax](https://en.wikipedia.org/wiki/C_syntax "C syntax") [Preprocessor](https://en.wikipedia.org/wiki/C_preprocessor "C preprocessor") [Data types](https://en.wikipedia.org/wiki/C_data_types "C data types") |
| [Standard library](https://en.wikipedia.org/wiki/C_standard_library "C standard library") | |
| | |
| [Char](https://en.wikipedia.org/wiki/C_character_classification "C character classification") [File I/O](https://en.wikipedia.org/wiki/C_file_input/output "C file input/output") [Math](https://en.wikipedia.org/wiki/C_mathematical_functions "C mathematical functions") [Dynamic memory](https://en.wikipedia.org/wiki/C_dynamic_memory_allocation "C dynamic memory allocation") [String](https://en.wikipedia.org/wiki/C_string_handling "C string handling") [Time](https://en.wikipedia.org/wiki/C_date_and_time_functions "C date and time functions") [Variadic](https://en.wikipedia.org/wiki/Stdarg.h "Stdarg.h") [POSIX](https://en.wikipedia.org/wiki/C_POSIX_library "C POSIX library") | |
| Implementations | [Bionic](https://en.wikipedia.org/wiki/Bionic_\(software\) "Bionic (software)") [libhybris](https://en.wikipedia.org/wiki/Hybris_\(software\) "Hybris (software)") [dietlibc](https://en.wikipedia.org/wiki/Dietlibc "Dietlibc") [glibc](https://en.wikipedia.org/wiki/Glibc "Glibc") [EGLIBC](https://en.wikipedia.org/wiki/Embedded_GLIBC "Embedded GLIBC") [klibc](https://en.wikipedia.org/wiki/Klibc "Klibc") [Windows CRT](https://en.wikipedia.org/wiki/Microsoft_Windows_library_files "Microsoft Windows library files") [musl](https://en.wikipedia.org/wiki/Musl "Musl") [Newlib](https://en.wikipedia.org/wiki/Newlib "Newlib") [uClibc](https://en.wikipedia.org/wiki/UClibc "UClibc") |
| [Compilers](https://en.wikipedia.org/wiki/List_of_C_compilers "List of C compilers") | [ACK](https://en.wikipedia.org/wiki/Amsterdam_Compiler_Kit "Amsterdam Compiler Kit") [Borland Turbo C](https://en.wikipedia.org/wiki/Borland_Turbo_C "Borland Turbo C") [Clang](https://en.wikipedia.org/wiki/Clang "Clang") [Comeau C/C++](https://en.wikipedia.org/wiki/Comeau_C/C%2B%2B "Comeau C/C++") [CompCert](https://en.wikipedia.org/wiki/CompCert "CompCert") [GCC](https://en.wikipedia.org/wiki/GNU_Compiler_Collection "GNU Compiler Collection") [IAR Embedded Workbench](https://en.wikipedia.org/wiki/IAR_Systems#IAR_Embedded_Workbench "IAR Systems") [ICC](https://en.wikipedia.org/wiki/Intel_C%2B%2B_Compiler "Intel C++ Compiler") [LCC](https://en.wikipedia.org/wiki/LCC_\(compiler\) "LCC (compiler)") [Norcroft C](https://en.wikipedia.org/wiki/Norcroft_C_compiler "Norcroft C compiler") [PCC](https://en.wikipedia.org/wiki/Portable_C_Compiler "Portable C Compiler") [SDCC](https://en.wikipedia.org/wiki/Small_Device_C_Compiler "Small Device C Compiler") [TCC](https://en.wikipedia.org/wiki/Tiny_C_Compiler "Tiny C Compiler") [Visual C++ (MSVC)](https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B "Microsoft Visual C++") [Watcom C/C++](https://en.wikipedia.org/wiki/Watcom_C/C%2B%2B "Watcom C/C++") |
| [IDEs](https://en.wikipedia.org/wiki/Integrated_development_environment "Integrated development environment") | [Anjuta](https://en.wikipedia.org/wiki/Anjuta "Anjuta") [CLion](https://en.wikipedia.org/wiki/CLion "CLion") [Code::Blocks](https://en.wikipedia.org/wiki/Code::Blocks "Code::Blocks") [CodeLite](https://en.wikipedia.org/wiki/CodeLite "CodeLite") [Eclipse](https://en.wikipedia.org/wiki/Eclipse_\(software\) "Eclipse (software)") [Geany](https://en.wikipedia.org/wiki/Geany "Geany") [GNOME Builder](https://en.wikipedia.org/wiki/GNOME_Builder "GNOME Builder") [KDevelop](https://en.wikipedia.org/wiki/KDevelop "KDevelop") [NetBeans](https://en.wikipedia.org/wiki/NetBeans "NetBeans") [Visual Studio](https://en.wikipedia.org/wiki/Visual_Studio "Visual Studio") |
| Comparison with other languages | [Compatibility of C and C++](https://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B "Compatibility of C and C++") [Comparison with Pascal](https://en.wikipedia.org/wiki/Comparison_of_Pascal_and_C "Comparison of Pascal and C") |
| Descendant languages | [Alef](https://en.wikipedia.org/wiki/Alef_\(programming_language\) "Alef (programming language)") [C++](https://en.wikipedia.org/wiki/C%2B%2B "C++") [C\#](https://en.wikipedia.org/wiki/C_Sharp_\(programming_language\) "C Sharp (programming language)") [D](https://en.wikipedia.org/wiki/D_\(programming_language\) "D (programming language)") [Objective-C](https://en.wikipedia.org/wiki/Objective-C "Objective-C") [Go](https://en.wikipedia.org/wiki/Go_\(programming_language\) "Go (programming language)") [Vala](https://en.wikipedia.org/wiki/Vala_\(programming_language\) "Vala (programming language)") [Zig](https://en.wikipedia.org/wiki/Zig_\(programming_language\) "Zig (programming language)") |
| Designer | [Dennis Ritchie](https://en.wikipedia.org/wiki/Dennis_Ritchie "Dennis Ritchie") |
|  **[Category](https://en.wikipedia.org/wiki/Category:C_\(programming_language\) "Category:C (programming language)")** | |
| [v](https://en.wikipedia.org/wiki/Template:C%2B%2B_programming_language "Template:C++ programming language") [t](https://en.wikipedia.org/wiki/Template_talk:C%2B%2B_programming_language "Template talk:C++ programming language") [e](https://en.wikipedia.org/wiki/Special:EditPage/Template:C%2B%2B_programming_language "Special:EditPage/Template:C++ programming language")[C++](https://en.wikipedia.org/wiki/C%2B%2B "C++") | |
|---|---|
| [C++](https://en.wikipedia.org/wiki/C%2B%2B "C++") [Outline](https://en.wikipedia.org/wiki/Outline_of_C%2B%2B "Outline of C++") [C++98](https://en.wikipedia.org/wiki/C%2B%2B#Standardization "C++") [C++03](https://en.wikipedia.org/wiki/C%2B%2B03 "C++03") [C++11](https://en.wikipedia.org/wiki/C%2B%2B11 "C++11") [C++14](https://en.wikipedia.org/wiki/C%2B%2B14 "C++14") [C++17](https://en.wikipedia.org/wiki/C%2B%2B17 "C++17") [C++20](https://en.wikipedia.org/wiki/C%2B%2B20 "C++20") [C++23](https://en.wikipedia.org/wiki/C%2B%2B23 "C++23") [C++26](https://en.wikipedia.org/wiki/C%2B%2B26 "C++26") [Libraries](https://en.wikipedia.org/wiki/Category:C%2B%2B_libraries "Category:C++ libraries") | |
| Features | [C++ syntax](https://en.wikipedia.org/wiki/C%2B%2B_syntax "C++ syntax") [Classes](https://en.wikipedia.org/wiki/C%2B%2B_classes "C++ classes") [Concepts](https://en.wikipedia.org/wiki/Concepts_\(C%2B%2B\) "Concepts (C++)") [Copy constructor](https://en.wikipedia.org/wiki/Copy_constructor_\(C%2B%2B\) "Copy constructor (C++)") [Exception handling](https://en.wikipedia.org/wiki/C%2B%2B#Exception_handling "C++") ([Exception safety](https://en.wikipedia.org/wiki/Exception_safety "Exception safety")) [Function overloading](https://en.wikipedia.org/wiki/Function_overloading "Function overloading") [Modules](https://en.wikipedia.org/wiki/Modules_\(C%2B%2B\) "Modules (C++)") [Move semantics](https://en.wikipedia.org/wiki/C%2B%2B11#Rvalue_references_and_move_constructors "C++11") [new and delete](https://en.wikipedia.org/wiki/New_and_delete_\(C%2B%2B\) "New and delete (C++)") [Operator overloading](https://en.wikipedia.org/wiki/Operator_overloading "Operator overloading") [Operators]() [Preprocessor](https://en.wikipedia.org/wiki/C_preprocessor "C preprocessor") [References](https://en.wikipedia.org/wiki/Reference_\(C%2B%2B\) "Reference (C++)") [Templates](https://en.wikipedia.org/wiki/Template_\(C%2B%2B\) "Template (C++)") [Virtual functions](https://en.wikipedia.org/wiki/Virtual_function "Virtual function") [placement syntax](https://en.wikipedia.org/wiki/Placement_syntax "Placement syntax") |
| [Standard Library](https://en.wikipedia.org/wiki/C%2B%2B_Standard_Library "C++ Standard Library") | [I/O Streams](https://en.wikipedia.org/wiki/Input/output_\(C%2B%2B\) "Input/output (C++)") [Smart pointers](https://en.wikipedia.org/wiki/Smart_pointer "Smart pointer") [STL](https://en.wikipedia.org/wiki/Standard_Template_Library "Standard Template Library") [Strings](https://en.wikipedia.org/wiki/C%2B%2B_string_handling "C++ string handling") |
| Ideas | [As-if rule](https://en.wikipedia.org/wiki/As-if_rule "As-if rule") [Barton–Nackman trick](https://en.wikipedia.org/wiki/Barton%E2%80%93Nackman_trick "Barton–Nackman trick") [Curiously recurring template pattern](https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern "Curiously recurring template pattern") [Freestanding](https://en.wikipedia.org/wiki/Freestanding_\(C%2B%2B_implementation\) "Freestanding (C++ implementation)") [Most vexing parse](https://en.wikipedia.org/wiki/Most_vexing_parse "Most vexing parse") [One Definition Rule](https://en.wikipedia.org/wiki/One_Definition_Rule "One Definition Rule") [Resource acquisition is initialization](https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization "Resource acquisition is initialization") [Rule of three](https://en.wikipedia.org/wiki/Rule_of_three_\(C%2B%2B_programming\) "Rule of three (C++ programming)") [Slicing](https://en.wikipedia.org/wiki/Object_slicing "Object slicing") [Special member functions](https://en.wikipedia.org/wiki/Special_member_functions "Special member functions") [Substitution failure is not an error](https://en.wikipedia.org/wiki/Substitution_failure_is_not_an_error "Substitution failure is not an error") [Template metaprogramming](https://en.wikipedia.org/wiki/Template_metaprogramming "Template metaprogramming") |
| [Compilers](https://en.wikipedia.org/wiki/Category:C%2B%2B_compilers "Category:C++ compilers") | [Comparison of C++ compilers](https://en.wikipedia.org/wiki/List_of_compilers#C++_compilers "List of compilers") *[Borland C++](https://en.wikipedia.org/wiki/Borland_C%2B%2B "Borland C++")* *[Borland Turbo C++](https://en.wikipedia.org/wiki/Borland_C%2B%2B "Borland C++")* [C++Builder](https://en.wikipedia.org/wiki/C%2B%2BBuilder "C++Builder") [Clang](https://en.wikipedia.org/wiki/Clang "Clang") [Comeau C/C++](https://en.wikipedia.org/wiki/Comeau_C/C%2B%2B "Comeau C/C++") [GCC](https://en.wikipedia.org/wiki/GNU_Compiler_Collection "GNU Compiler Collection") [IAR Embedded Workbench](https://en.wikipedia.org/wiki/IAR_Systems#IAR_Embedded_Workbench "IAR Systems") [Intel C++ Compiler](https://en.wikipedia.org/wiki/Intel_C%2B%2B_Compiler "Intel C++ Compiler") [Oracle Solaris Studio](https://en.wikipedia.org/wiki/Oracle_Developer_Studio "Oracle Developer Studio") [Visual C++ (MSVC)](https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B "Microsoft Visual C++") [Watcom C/C++](https://en.wikipedia.org/wiki/Watcom_C/C%2B%2B "Watcom C/C++") |
| [IDEs](https://en.wikipedia.org/wiki/Category:Integrated_development_environments "Category:Integrated development environments") | [Comparison of C IDEs](https://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#C/C++ "Comparison of integrated development environments") *[Anjuta](https://en.wikipedia.org/wiki/Anjuta "Anjuta")* [CLion](https://en.wikipedia.org/wiki/CLion "CLion") [Code::Blocks](https://en.wikipedia.org/wiki/Code::Blocks "Code::Blocks") [CodeLite](https://en.wikipedia.org/wiki/CodeLite "CodeLite") [Dev-C++](https://en.wikipedia.org/wiki/Dev-C%2B%2B "Dev-C++") [Eclipse](https://en.wikipedia.org/wiki/Eclipse_\(software\) "Eclipse (software)") [Geany](https://en.wikipedia.org/wiki/Geany "Geany") [NetBeans](https://en.wikipedia.org/wiki/NetBeans "NetBeans") [KDevelop](https://en.wikipedia.org/wiki/KDevelop "KDevelop") [Qt Creator](https://en.wikipedia.org/wiki/Qt_Creator "Qt Creator") [Visual Studio](https://en.wikipedia.org/wiki/Visual_Studio "Visual Studio") |
| Superset languages | [Objective-C++](https://en.wikipedia.org/wiki/Objective-C%2B%2B "Objective-C++") [C++/CLI](https://en.wikipedia.org/wiki/C%2B%2B/CLI "C++/CLI") [C++/CX](https://en.wikipedia.org/wiki/C%2B%2B/CX "C++/CX") [C++/WinRT](https://en.wikipedia.org/wiki/C%2B%2B/WinRT "C++/WinRT") [Ch](https://en.wikipedia.org/wiki/Ch_\(computer_programming\) "Ch (computer programming)") [SYCL](https://en.wikipedia.org/wiki/SYCL "SYCL") |
| Dialects | [Embedded C++](https://en.wikipedia.org/wiki/Embedded_C%2B%2B "Embedded C++") |
| Relative to other languages | [Comparison of programming languages](https://en.wikipedia.org/wiki/Comparison_of_programming_languages "Comparison of programming languages") [Comparison of Java and C++](https://en.wikipedia.org/wiki/Comparison_of_Java_and_C%2B%2B "Comparison of Java and C++") [Compatibility of C and C++](https://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B "Compatibility of C and C++") [Criticism of C++](https://en.wikipedia.org/wiki/Criticism_of_C%2B%2B "Criticism of C++") |
| People | [David Abrahams](https://en.wikipedia.org/wiki/David_Abrahams_\(computer_programmer\) "David Abrahams (computer programmer)") [Andrei Alexandrescu](https://en.wikipedia.org/wiki/Andrei_Alexandrescu "Andrei Alexandrescu") [Pete Becker](https://en.wikipedia.org/wiki/Pete_Becker "Pete Becker") [Rick Mascitti](https://en.wikipedia.org/wiki/Rick_Mascitti "Rick Mascitti") [Scott Meyers](https://en.wikipedia.org/wiki/Scott_Meyers "Scott Meyers") [Alexander Stepanov](https://en.wikipedia.org/wiki/Alexander_Stepanov "Alexander Stepanov") [Bjarne Stroustrup](https://en.wikipedia.org/wiki/Bjarne_Stroustrup "Bjarne Stroustrup") [Herb Sutter](https://en.wikipedia.org/wiki/Herb_Sutter "Herb Sutter") |
|  **[Category](https://en.wikipedia.org/wiki/Category:C%2B%2B_programming_language_family "Category:C++ programming language family")** | |

Retrieved from "[https://en.wikipedia.org/w/index.php?title=Operators\_in\_C\_and\_C%2B%2B\&oldid=1337146407](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&oldid=1337146407)"
[Categories](https://en.wikipedia.org/wiki/Help:Category "Help:Category"):
- [C (programming language)](https://en.wikipedia.org/wiki/Category:C_\(programming_language\) "Category:C (programming language)")
- [C++](https://en.wikipedia.org/wiki/Category:C%2B%2B "Category:C++")
- [Operators (programming)](https://en.wikipedia.org/wiki/Category:Operators_\(programming\) "Category:Operators (programming)")
- [Comparison of individual programming languages](https://en.wikipedia.org/wiki/Category:Comparison_of_individual_programming_languages "Category:Comparison of individual programming languages")
Hidden categories:
- [Articles with example C++ code](https://en.wikipedia.org/wiki/Category:Articles_with_example_C%2B%2B_code "Category:Articles with example C++ code")
- [All articles with unsourced statements](https://en.wikipedia.org/wiki/Category:All_articles_with_unsourced_statements "Category:All articles with unsourced statements")
- [Articles with unsourced statements from July 2024](https://en.wikipedia.org/wiki/Category:Articles_with_unsourced_statements_from_July_2024 "Category:Articles with unsourced statements from July 2024")
- [Articles with short description](https://en.wikipedia.org/wiki/Category:Articles_with_short_description "Category:Articles with short description")
- [Short description is different from Wikidata](https://en.wikipedia.org/wiki/Category:Short_description_is_different_from_Wikidata "Category:Short description is different from Wikidata")
- [Use American English from March 2019](https://en.wikipedia.org/wiki/Category:Use_American_English_from_March_2019 "Category:Use American English from March 2019")
- [All Wikipedia articles written in American English](https://en.wikipedia.org/wiki/Category:All_Wikipedia_articles_written_in_American_English "Category:All Wikipedia articles written in American English")
- [Use dmy dates from December 2019](https://en.wikipedia.org/wiki/Category:Use_dmy_dates_from_December_2019 "Category:Use dmy dates from December 2019")
- [Pages displaying short descriptions of redirect targets via Module:Annotated link](https://en.wikipedia.org/wiki/Category:Pages_displaying_short_descriptions_of_redirect_targets_via_Module:Annotated_link "Category:Pages displaying short descriptions of redirect targets via Module:Annotated link")
- This page was last edited on 7 February 2026, at 19:26 (UTC).
- Text is available under the [Creative Commons Attribution-ShareAlike 4.0 License](https://en.wikipedia.org/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License "Wikipedia:Text of the Creative Commons Attribution-ShareAlike 4.0 International License"); additional terms may apply. By using this site, you agree to the [Terms of Use](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use "foundation:Special:MyLanguage/Policy:Terms of Use") and [Privacy Policy](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy "foundation:Special:MyLanguage/Policy:Privacy policy"). Wikipedia® is a registered trademark of the [Wikimedia Foundation, Inc.](https://wikimediafoundation.org/), a non-profit organization.
- [Privacy policy](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy)
- [About Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:About)
- [Disclaimers](https://en.wikipedia.org/wiki/Wikipedia:General_disclaimer)
- [Contact Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:Contact_us)
- [Legal & safety contacts](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Legal:Wikimedia_Foundation_Legal_and_Safety_Contact_Information)
- [Code of Conduct](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct)
- [Developers](https://developer.wikimedia.org/)
- [Statistics](https://stats.wikimedia.org/#/en.wikipedia.org)
- [Cookie statement](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement)
- [Mobile view](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&mobileaction=toggle_view_mobile)
- [](https://www.wikimedia.org/)
- [](https://www.mediawiki.org/)
Search
Toggle the table of contents
Operators in C and C++
12 languages
[Add topic](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B) |
| Readable Markdown | From Wikipedia, the free encyclopedia
This is a list of [operators](https://en.wikipedia.org/wiki/Operator_\(programming\) "Operator (programming)") in the [C](https://en.wikipedia.org/wiki/C_\(programming_language\) "C (programming language)") and [C++](https://en.wikipedia.org/wiki/C%2B%2B "C++") [programming languages](https://en.wikipedia.org/wiki/Programming_language "Programming language").
All listed operators are in C++ and lacking indication otherwise, in C as well. Some tables include a "In C" column that indicates whether an operator is also in C. Note that C does not support [operator overloading](https://en.wikipedia.org/wiki/Operator_overloading "Operator overloading").
When not overloaded, for the operators `&&`, `||`, and `,` (the [comma operator](https://en.wikipedia.org/wiki/Comma_operator "Comma operator")), there is a [sequence point](https://en.wikipedia.org/wiki/Sequence_point "Sequence point") after the evaluation of the first operand.
Most of the operators available in C and C++ are also available in other [C-family](https://en.wikipedia.org/wiki/C-family "C-family") languages such as [C\#](https://en.wikipedia.org/wiki/C_Sharp_\(programming_language\) "C Sharp (programming language)"), [D](https://en.wikipedia.org/wiki/D_\(programming_language\) "D (programming language)"), [Java](https://en.wikipedia.org/wiki/Java_\(programming_language\) "Java (programming language)"), [Perl](https://en.wikipedia.org/wiki/Perl "Perl"), and [PHP](https://en.wikipedia.org/wiki/PHP "PHP") with the same precedence, associativity, and semantics.
Many operators specified by a sequence of symbols are commonly referred to by a name that consists of the name of each symbol. For example, `+=` and `-=` are often called "plus equal(s)" and "minus equal(s)", instead of the more verbose "assignment by addition" and "assignment by subtraction".
In the following tables, lower case letters such as `a` and `b` represent literal values, object/variable names, or l-values, as appropriate. `R`, `S` and `T` stand for a data type, and `K` for a class or enumeration type. Some operators have alternative spellings using [digraphs and trigraphs](https://en.wikipedia.org/wiki/Digraphs_and_trigraphs_\(programming\) "Digraphs and trigraphs (programming)") or [operator synonyms](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Synonyms).
C and C++ have the same arithmetic operators and all can be overloaded in C++.
| Operation | Syntax | C++ prototype | |
|---|---|---|---|
| in class K | outside class | | |
| [Addition](https://en.wikipedia.org/wiki/Addition "Addition") | `a + b` | `R K::operator +(S b);` | `R operator +(K a, S b);` |
| [Subtraction](https://en.wikipedia.org/wiki/Subtraction "Subtraction") | `a - b` | `R K::operator -(S b);` | `R operator -(K a, S b);` |
| [Unary](https://en.wikipedia.org/wiki/Unary_operation "Unary operation") plus; [integer promotion](https://en.wikipedia.org/wiki/Type_conversion#Type_promotion "Type conversion") | `+a` | `R K::operator +();` | `R operator +(K a);` |
| [Unary](https://en.wikipedia.org/wiki/Unary_operation "Unary operation") minus; [additive inverse](https://en.wikipedia.org/wiki/Additive_inverse "Additive inverse") | `-a` | `R K::operator -();` | `R operator -(K a);` |
| [Multiplication](https://en.wikipedia.org/wiki/Multiplication "Multiplication") | `a * b` | `R K::operator *(S b);` | `R operator *(K a, S b);` |
| [Division](https://en.wikipedia.org/wiki/Division_\(mathematics\) "Division (mathematics)") | `a / b` | `R K::operator /(S b);` | `R operator /(K a, S b);` |
| [Modulo](https://en.wikipedia.org/wiki/Modulo_operation "Modulo operation")[\[a\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-modulo-1) | `a % b` | `R K::operator %(S b);` | `R operator %(K a, S b);` |
| Prefix [increment](https://en.wikipedia.org/wiki/Increment_and_decrement_operators "Increment and decrement operators") | `++a` | `R& K::operator ++();` | `R& operator ++(K& a);` |
| Postfix increment | `a++` | `R K::operator ++(int);`[\[b\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-dummy-int-2) | `R operator ++(K& a, int);`[\[b\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-dummy-int-2) |
| Prefix [decrement](https://en.wikipedia.org/wiki/Increment_and_decrement_operators "Increment and decrement operators") | `--a` | `R& K::operator --();` | `R& operator --(K& a);` |
| Postfix decrement | `a--` | `R K::operator --(int);`[\[b\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-dummy-int-2) | `R operator --(K& a, int);`[\[b\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-dummy-int-2) |
All [relational](https://en.wikipedia.org/wiki/Relational_operator "Relational operator") (comparison) operators can be overloaded in C++. Since [C++20](https://en.wikipedia.org/wiki/C%2B%2B20 "C++20"), the inequality operator is automatically generated if `operator==` is defined and all four relational operators are automatically generated if `operator<=>` is defined.[\[1\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-3)
| Operation | Syntax | In C | C++ prototype | |
|---|---|---|---|---|
| in class K | outside class | | | |
| Equal to | `a == b` | Yes | `bool K::operator ==(S const& b) const;` | `bool operator ==(K const& a, S const& b);` |
| Not equal to | `a != b` | Yes | `bool K::operator !=(S const& b) const;` | `bool operator !=(K const& a, S const& b);` |
| Greater than | `a > b` | Yes | `bool K::operator >(S const& b) const;` | `bool operator >(K const& a, S const& b);` |
| Less than | `a < b` | Yes | `bool K::operator <(S const& b) const;` | `bool operator <(K const& a, S const& b);` |
| Greater than or equal to | `a >= b` | Yes | `bool K::operator >=(S const& b) const;` | `bool operator >=(K const& a, S const& b);` |
| Less than or equal to | `a <= b` | Yes | `bool K::operator <=(S const& b) const;` | `bool operator <=(K const& a, S const& b);` |
| [Three-way comparison](https://en.wikipedia.org/wiki/Three-way_comparison "Three-way comparison")[\[c\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-threewaycomparison-4)[\[d\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-5) | `a <=> b` | No | `auto K::operator <=>(const S &b);` | `auto operator <=>(const K &a, const S &b);` |
C and C++ have the same logical operators and all can be overloaded in C++.
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](https://en.wikipedia.org/wiki/Short-circuit_evaluation "Short-circuit evaluation").[\[2\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-6)
| Operation | Syntax | C++ prototype | |
|---|---|---|---|
| in class K | outside class | | |
| [NOT](https://en.wikipedia.org/wiki/Negation "Negation") | `!a` | `bool K::operator !();` | `bool operator !(K a);` |
| [AND](https://en.wikipedia.org/wiki/Logical_conjunction "Logical conjunction") | `a && b` | `bool K::operator &&(S b);` | `bool operator &&(K a, S b);` |
| [OR](https://en.wikipedia.org/wiki/Logical_disjunction "Logical disjunction") | `a || b` | `bool K::operator ||(S b);` | `bool operator ||(K a, S b);` |
C and C++ have the same bitwise operators and all can be overloaded in C++.
| Operation | Syntax | C++ prototype | |
|---|---|---|---|
| in class K | outside class | | |
| [NOT](https://en.wikipedia.org/wiki/Bitwise_operation#NOT "Bitwise operation") | `~a` | `R K::operator ~();` | `R operator ~(K a);` |
| [AND](https://en.wikipedia.org/wiki/Bitwise_operation#AND "Bitwise operation") | `a & b` | `R K::operator &(S b);` | `R operator &(K a, S b);` |
| [OR](https://en.wikipedia.org/wiki/Bitwise_operation#OR "Bitwise operation") | `a | b` | `R K::operator |(S b);` | `R operator |(K a, S b);` |
| [XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR "Bitwise operation") | `a ^ b` | `R K::operator ^(S b);` | `R operator ^(K a, S b);` |
| [Shift](https://en.wikipedia.org/wiki/Bitwise_shift "Bitwise shift") left[\[e\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-bitshift-7) | `a << b` | `R K::operator <<(S b);` | `R operator <<(K a, S b);` |
| Shift right[\[e\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-bitshift-7)[\[f\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-9) | `a >> b` | `R K::operator >>(S b);` | `R operator >>(K a, S b);` |
C and C++ have the same assignment operators and all can be overloaded in C++.
For the combination operators, `a ⊚= b` (where `⊚` represents an operation) is equivalent to `a = a ⊚ b`, except that `a` is evaluated only once.
| Operation | Syntax | C++ prototype | |
|---|---|---|---|
| in class K | outside class | | |
| [Assignment](https://en.wikipedia.org/wiki/Assignment_operator_\(C%2B%2B\) "Assignment operator (C++)") | `a = b` | `R& K::operator =(S b);` | N/a |
| Addition combination | `a += b` | `R& K::operator +=(S b);` | `R& operator +=(K& a, S b);` |
| Subtraction combination | `a -= b` | `R& K::operator -=(S b);` | `R& operator -=(K& a, S b);` |
| Multiplication combination | `a *= b` | `R& K::operator *=(S b);` | `R& operator *=(K& a, S b);` |
| Division combination | `a /= b` | `R& K::operator /=(S b);` | `R& operator /=(K& a, S b);` |
| Modulo combination | `a %= b` | `R& K::operator %=(S b);` | `R& operator %=(K& a, S b);` |
| Bitwise AND combination | `a &= b` | `R& K::operator &=(S b);` | `R& operator &=(K& a, S b);` |
| Bitwise OR combination | `a |= b` | `R& K::operator |=(S b);` | `R& operator |=(K& a, S b);` |
| Bitwise XOR combination | `a ^= b` | `R& K::operator ^=(S b);` | `R& operator ^=(K& a, S b);` |
| Bitwise left shift combination | `a <<= b` | `R& K::operator <<=(S b);` | `R& operator <<=(K& a, S b);` |
| Bitwise right shift combination[\[g\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-rightbitshift-10) | `a >>= b` | `R& K::operator >>=(S b);` | `R& operator >>=(K& a, S b);` |
| Operation | Syntax | Can overload | In C | C++ prototype | |
|---|---|---|---|---|---|
| in class K | outside class | | | | |
| [Subscript](https://en.wikipedia.org/wiki/Indexer_\(programming\) "Indexer (programming)") | `a[b]``a<:b:>`[\[4\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-11) | Yes | Yes | `R& K::operator [](S b);` `R& K::operator [](S b, ...);`[\[h\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX23-12) | N/a |
| Indirection (object pointed to by *a*) | `*a` | Yes | Yes | `R& K::operator *();` | `R& operator *(K a);` |
| Address-of (address of *a*) | `&a` | Yes[\[i\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-addressof2-13) | Yes | `R* K::operator &();` | `R* operator &(K a);` |
| Structure dereference (member *b* of object pointed to by *a*) | `a->b` | Yes | Yes | `R* K::operator ->();`[\[j\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-arrowptr-14) | N/a |
| Structure reference (member *b* of object *a*) | `a.b` | No | Yes | N/a | |
| Member selected by [pointer-to-member](https://en.wikipedia.org/wiki/Pointer-to-member "Pointer-to-member") *b* of object pointed to by *a*[\[k\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-arrowstar-15) | `a->*b` | Yes | No | `R& K::operator ->*(S b);` | `R& operator ->*(K a, S b);` |
| Member of object *a* selected by [pointer-to-member](https://en.wikipedia.org/wiki/Pointer-to-member "Pointer-to-member") *b* | `a.*b` | No | No | N/a | |
| Operation | Syntax | Can overload | In C | C++ prototype | |
|---|---|---|---|---|---|
| in class K | outside class | | | | |
| [Function](https://en.wikipedia.org/wiki/Function_\(programming\) "Function (programming)") call | `a(a1, a2)` | Yes | Yes | `R K::operator ()(S a, T b, ...);` | N/a |
| [Comma](https://en.wikipedia.org/wiki/Comma_operator "Comma operator") | `a, b` | Yes | Yes | `R K::operator ,(S b);` | `R operator ,(K a, S b);` |
| [Ternary conditional](https://en.wikipedia.org/wiki/%3F: "?:") | `a ? b : c` | No | Yes | N/a | |
| [Scope resolution](https://en.wikipedia.org/wiki/Scope_resolution_operator#C++ "Scope resolution operator") | `a::b`[\[l\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-scopal-16) | No | No | N/a | |
| User-defined literals[\[m\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-ud-literal-17)[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) | `"a"_b` | Yes | No | N/a | `R operator "" _b(T a)` |
| [Sizeof](https://en.wikipedia.org/wiki/Sizeof "Sizeof") | `sizeof a`[\[o\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sizeof-19) `sizeof (R)` | No | Yes | N/a | |
| Size of [parameter pack](https://en.wikipedia.org/wiki/Variadic_template "Variadic template")[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) | `sizeof...(Args)` | No | No | N/a | |
| Alignof[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) | `alignof(R)` or `_Alignof(R)`[\[p\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-alignof-20) | No | Yes | N/a | |
| [Typeof](https://en.wikipedia.org/wiki/Typeof "Typeof")[\[q\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-typeof-21) | `typeof(a)` `typeof(R)` `typeof_unqual(a)` `typeof_unqual(R)` | N/a | Yes | N/a | |
| [Decltype](https://en.wikipedia.org/wiki/Decltype "Decltype")[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) | `decltype(a)` `decltype(R)` | No | No | N/a | |
| Type identification | `typeid(a)` `typeid(R)` | No | No | N/a | |
| [Conversion](https://en.wikipedia.org/wiki/Type_conversion "Type conversion") (C-style cast) | `(R)a` | Yes | Yes | `K::operator R();`[\[5\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-22) | N/a |
| [Conversion](https://en.wikipedia.org/wiki/Type_conversion "Type conversion")[\[r\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-23)[\[6\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-24) | `R(a)` `R{a}`[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) `auto(a)`[\[h\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX23-12) `auto{a}`[\[h\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX23-12) | No | No | N/a | |
| [static\_cast](https://en.wikipedia.org/wiki/Static_cast "Static cast") conversion[\[s\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-25) | `static_cast<R>(a)` | Yes | No | `K::operator R();` `explicit K::operator R();`[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) | N/a |
| [dynamic cast](https://en.wikipedia.org/wiki/Dynamic_cast "Dynamic cast") conversion | `dynamic_cast<R>(a)` | No | No | N/a | |
| [const\_cast](https://en.wikipedia.org/wiki/Const_cast "Const cast") conversion | `const_cast<R>(a)` | No | No | N/a | |
| [reinterpret\_cast](https://en.wikipedia.org/wiki/Reinterpret_cast "Reinterpret cast") conversion | `reinterpret_cast<R>(a)` | No | No | N/a | |
| [Allocate memory](https://en.wikipedia.org/wiki/New_\(c%2B%2B\) "New (c++)") | `new R`[\[t\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-infer-26) | Yes | No | `void* K::operator new(size_t x);` | `void* operator new(size_t x);` |
| Allocate array | `new R[n]`[\[u\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-infer2-27) | Yes | No | `void* K::operator new[](size_t a);` | `void* operator new[](size_t a);` |
| [Deallocate memory](https://en.wikipedia.org/wiki/Operator_delete "Operator delete") | `delete a` | Yes | No | `void K::operator delete(void* a);` | `void operator delete(void* a);` |
| Deallocate array | `delete[] a` | Yes | No | `void K::operator delete[](void* a);` | `void operator delete[](void* a);` |
| Exception check[\[n\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX11-18) | `noexcept(a)` | No | No | N/a | |
| [Reflection](https://en.wikipedia.org/wiki/Reflective_programming "Reflective programming")[\[v\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-sinceCXX26-28) | `^^a` | No | No | N/a | |
C++ defines keywords to act as aliases for a number of operators:[\[7\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-Committee-29)
| Keyword | Operator |
|---|---|
| `and` | `&&` |
| `and_eq` | `&=` |
| `bitand` | `&` |
| `bitor` | `|` |
| `compl` | `~` |
| `not` | `!` |
| `not_eq` | `!=` |
| `or` | `||` |
| `or_eq` | `|=` |
| `xor` | `^` |
| `xor_eq` | `^=` |
Each keyword is a different way to specify an operator and as such can be used instead of the corresponding symbolic variation. For example, `(a > 0 and not flag)` and `(a > 0 && !flag)` specify the same behavior. As another example, the `bitand` keyword may be used to replace not only the *bitwise-and* operator but also the *address-of* operator, and it can be used to specify reference types (e.g., `int bitand ref = n`).
The ISO C specification makes allowance for these keywords as preprocessor macros in the header file [`iso646.h`](https://en.wikipedia.org/wiki/Iso646.h "Iso646.h"). For compatibility with C, C++ also provides the header `iso646.h`, the inclusion of which has no effect. Until C++20, it also provided the corresponding header [`ciso646`](https://en.wikipedia.org/wiki/Ciso646 "Ciso646") which had no effect as well.
## Expression evaluation order
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=10 "Edit section: Expression evaluation order")\]
During expression evaluation, the order in which sub-expressions are evaluated is determined by [precedence](https://en.wikipedia.org/wiki/Order_of_operations "Order of operations") and [associativity](https://en.wikipedia.org/wiki/Operator_associativity "Operator associativity"). An operator with higher precedence is evaluated before a operator of lower precedence and the operands of an operator are evaluated based on associativity. The following table describes the precedence and associativity of the C and C++ operators. Operators are shown in groups of equal precedence with groups ordered in descending precedence from top to bottom (lower order is higher precedence).[\[8\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-30)[\[9\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-31)[\[10\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-32)
Operator precedence is not affected by overloading.
| Order | Operator | Description | Associativity |
|---|---|---|---|
| 1 highest | `::` | [Scope resolution](https://en.wikipedia.org/wiki/Scope_resolution_operator#C.2B.2B "Scope resolution operator") (C++ only) | None |
| 2 | `++` | Postfix increment | Left-to-right |
| `--` | Postfix decrement | | |
| `()` | Function call | | |
| `[]` | Array subscripting | | |
| `.` | Element selection by reference | | |
| `->` | Element selection through pointer | | |
| `typeid()` | [Run-time type information](https://en.wikipedia.org/wiki/Run-time_type_information "Run-time type information") (C++ only) (see [typeid](https://en.wikipedia.org/wiki/Typeid "Typeid")) | | |
| `const_cast` | Type cast (C++ only) (see [const\_cast](https://en.wikipedia.org/wiki/Const_cast "Const cast")) | | |
| `dynamic_cast` | Type cast (C++ only) (see [dynamic cast](https://en.wikipedia.org/wiki/Dynamic_cast "Dynamic cast")) | | |
| `reinterpret_cast` | Type cast (C++ only) (see [reinterpret\_cast](https://en.wikipedia.org/wiki/Reinterpret_cast "Reinterpret cast")) | | |
| `static_cast` | Type cast (C++ only) (see [static\_cast](https://en.wikipedia.org/wiki/Static_cast "Static cast")) | | |
| 3 | `++` | Prefix increment | Right-to-left |
| `--` | Prefix decrement | | |
| `+` | Unary plus | | |
| `-` | Unary minus | | |
| `!` | Logical NOT | | |
| `~` | Bitwise NOT ([ones' complement](https://en.wikipedia.org/wiki/Ones%27_complement "Ones' complement")) | | |
| `(type)` | Type cast | | |
| `*` | Indirection (dereference) | | |
| `&` | Address-of | | |
| `sizeof` | [Sizeof](https://en.wikipedia.org/wiki/Sizeof "Sizeof") | | |
| `_Alignof` | Alignment requirement (since C11) | | |
| `new`, `new[]` | Dynamic memory allocation (C++ only) | | |
| `delete`, `delete[]` | Dynamic memory deallocation (C++ only) | | |
| 4 | `.*` | Pointer to member (C++ only) | Left-to-right |
| `->*` | Pointer to member (C++ only) | | |
| 5 | `*` | Multiplication | Left-to-right |
| `/` | Division | | |
| `%` | [Modulo](https://en.wikipedia.org/wiki/Modulo_operation "Modulo operation") (remainder) | | |
| 6 | `+` | Addition | Left-to-right |
| `-` | Subtraction | | |
| 7 | `<<` | [Bitwise](https://en.wikipedia.org/wiki/Bitwise_operation "Bitwise operation") left shift | Left-to-right |
| `>>` | [Bitwise](https://en.wikipedia.org/wiki/Bitwise_operation "Bitwise operation") right shift | | |
| 8 | `<=>` | [Three-way comparison](https://en.wikipedia.org/wiki/Three-way_comparison "Three-way comparison") (Introduced in [C++20](https://en.wikipedia.org/wiki/C%2B%2B20 "C++20") - C++ only) | Left-to-right |
| 9 | `<` | Less than | Left-to-right |
| `<=` | Less than or equal to | | |
| `>` | Greater than | | |
| `>=` | Greater than or equal to | | |
| 10 | `==` | Equal to | Left-to-right |
| `!=` | Not equal to | | |
| 11 | `&` | Bitwise AND | Left-to-right |
| 12 | `^` | Bitwise XOR (exclusive or) | Left-to-right |
| 13 | `|` | Bitwise OR (inclusive or) | Left-to-right |
| 14 | `&&` | Logical AND | Left-to-right |
| 15 | `||` | Logical OR | Left-to-right |
| 16 | `co_await` | Coroutine processing (C++ only) | Right-to-left |
| `co_yield` | | | |
| 17 | `?:` | [Ternary conditional operator](https://en.wikipedia.org/wiki/Ternary_conditional_operator "Ternary conditional operator") | Right-to-left |
| `=` | Direct assignment | | |
| `+=` | Assignment by sum | | |
| `-=` | Assignment by difference | | |
| `*=` | Assignment by product | | |
| `/=` | Assignment by quotient | | |
| `%=` | Assignment by remainder | | |
| `<<=` | Assignment by bitwise left shift | | |
| `>>=` | Assignment by bitwise right shift | | |
| `&=` | Assignment by bitwise AND | | |
| `^=` | Assignment by bitwise XOR | | |
| `|=` | Assignment by bitwise OR | | |
| `throw` | Throw operator (exceptions throwing, C++ only) | | |
| 18 lowest | `,` | [Comma](https://en.wikipedia.org/wiki/Comma_operator "Comma operator") | Left-to-right |
Although this table is adequate for describing most evaluation order, it does not describe a few details. The [ternary operator](https://en.wikipedia.org/wiki/Ternary_operator "Ternary operator") allows any arbitrary expression as its middle operand, despite being listed as having higher precedence than the assignment and comma operators. Thus `a ? b, c : d` is interpreted as `a ? (b, c) : d`, and not as the meaningless `(a ? b), (c : d)`. So, the expression in the middle of the conditional operator (between `?` and `:`) is parsed as if parenthesized. Also, the immediate, un-parenthesized result of a C cast expression cannot be the operand of `sizeof`. Therefore, `sizeof (int) * x` is interpreted as `(sizeof(int)) * x` and not `sizeof ((int) * x)`.
### Chained expressions
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=12 "Edit section: Chained expressions")\]
The precedence table determines the order of binding in chained expressions, when it is not expressly specified by parentheses.
- For example, `++x*3` is ambiguous without some precedence rule(s). The precedence table tells us that: x is 'bound' more tightly to \++ than to \*, so that whatever \++ does (now or later—see below), it does it ONLY to x (and not to `x*3`); it is equivalent to (`++x`, `x*3`).
- Similarly, with `3*x++`, where though the post-fix \++ is designed to act AFTER the entire expression is evaluated, the precedence table makes it clear that ONLY x gets incremented (and NOT `3*x`). In fact, the expression (`tmp=x++`, `3*tmp`) is evaluated with tmp being a temporary value. It is functionally equivalent to something like (`tmp=3*x`, `++x`, `tmp`).
[](https://en.wikipedia.org/wiki/File:Precedence_2.png)
Precedence and bindings
- Abstracting the issue of precedence or binding, consider the diagram above for the expression 3+2\*y\[i\]++. The compiler's job is to resolve the diagram into an expression, one in which several unary operators (call them 3+( . ), 2\*( . ), ( . )++ and ( . )\[ i \]) are competing to bind to y. The order of precedence table resolves the final sub-expression they each act upon: ( . )\[ i \] acts only on y, ( . )++ acts only on y\[i\], 2\*( . ) acts only on y\[i\]++ and 3+( . ) acts 'only' on 2\*((y\[i\])++). It is important to note that WHAT sub-expression gets acted on by each operator is clear from the precedence table but WHEN each operator acts is not resolved by the precedence table; in this example, the ( . )++ operator acts only on y\[i\] by the precedence rules but binding levels alone do not indicate the timing of the postfix ++ (the ( . )++ operator acts only after y\[i\] is evaluated in the expression).
The binding of operators in C and C++ is specified by a factored language grammar, rather than a precedence table. This creates some subtle conflicts. For example, in C, the syntax for a conditional expression is:
```
logical-OR-expression ? expression : conditional-expression
```
while in C++ it is:
```
logical-OR-expression ? expression : assignment-expression
```
Hence, the expression:
```
e = a < d ? a++ : a = d
```
is parsed differently in the two languages. In C, this expression is a syntax error, because the syntax for an assignment expression in C is:
```
unary-expression '=' assignment-expression
```
In C++, it is parsed as:
```
e = (a < d ? a++ : (a = d))
```
which is a valid expression.[\[11\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-33)[\[12\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-34)
To use the comma operator in a function call argument expression, variable assignment, or a comma-separated list, use of parentheses is required.[\[13\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-35)[\[14\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-36) For example,
```
int a = 1, b = 2, weirdVariable = (++a, b), d = 4;
```
### Criticism of bitwise and equality operators precedence
\[[edit](https://en.wikipedia.org/w/index.php?title=Operators_in_C_and_C%2B%2B&action=edit§ion=14 "Edit section: Criticism of bitwise and equality operators precedence")\]
The precedence of the bitwise logical operators has been criticized.[\[15\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-Bell-37) Conceptually, & and \| are arithmetic operators like \* and +.
The expression `a & b == 7` is syntactically parsed as `a & (b == 7)` whereas the expression `a + b == 7` is parsed as `(a + b) == 7`. This requires parentheses to be used more often than they otherwise would.
Historically, there was no syntactic distinction between the bitwise and logical operators. In [BCPL](https://en.wikipedia.org/wiki/BCPL "BCPL"), [B](https://en.wikipedia.org/wiki/B_\(programming_language\) "B (programming language)") and early C, the operators `&& ||` didn't exist. Instead `& |` had different meaning depending on whether they are used in a 'truth-value context' (i.e. when a Boolean value was expected, for example in `if (a==b & c) {...}` it behaved as a logical operator, but in `c = a & b` it behaved as a bitwise one). It was retained so as to keep [backward compatibility](https://en.wikipedia.org/wiki/Backward_compatibility "Backward compatibility") with existing installations.[\[16\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-38)
Moreover, in C++ (and later versions of C) equality operations, with the exception of the three-way comparison operator, yield [bool](https://en.wikipedia.org/wiki/Boolean_data_type "Boolean data type") type values which are conceptually a single bit (1 or 0) and as such do not properly belong in "bitwise" operations.
1. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-modulo_1-0)** The modulus operator only supports integer operands; for floating point, a function such as [`fmod`](https://en.wikipedia.org/wiki/Math.h "Math.h") can be used.
2. ^ [***a***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-dummy-int_2-0) [***b***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-dummy-int_2-1) [***c***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-dummy-int_2-2) [***d***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-dummy-int_2-3) The `int` is a dummy parameter to differentiate between prefix and postfix.
3. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-threewaycomparison_4-0)** About [C++20 three-way comparison](https://en.cppreference.com/w/cpp/language/operator_comparison#Three-way_comparison)
4. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-5)** Possible return types: `std::weak_ordering`, `std::strong_ordering` and `std::partial_ordering` to which they all are convertible to.
5. ^ [***a***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-bitshift_7-0) [***b***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-bitshift_7-1) In the context of [iostreams](https://en.wikipedia.org/wiki/Iostream "Iostream") in C++, writers often will refer to `<<` and `>>` as the "put-to" or "stream insertion" and "get-from" or "stream extraction" operators, respectively.
6. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-9)** According to the C99 standard, the right shift of a negative number is implementation defined. Most implementations, e.g., the GCC,[\[3\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-Integers-8) use an [arithmetic shift](https://en.wikipedia.org/wiki/Arithmetic_shift "Arithmetic shift") (i.e., sign extension), but a [logical shift](https://en.wikipedia.org/wiki/Logical_shift "Logical shift") is possible.
7. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-rightbitshift_10-0)** According to the C99 standard, the right shift of a negative number is implementation defined. Most implementations, e.g., the GCC,[\[3\]](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_note-Integers-8) use an [arithmetic shift](https://en.wikipedia.org/wiki/Arithmetic_shift "Arithmetic shift") (i.e., sign extension), but a [logical shift](https://en.wikipedia.org/wiki/Logical_shift "Logical shift") is possible.
8. ^ [***a***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX23_12-0) [***b***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX23_12-1) [***c***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX23_12-2) since C++23
9. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-addressof2_13-0)** The actual address of an object with an overloaded `operator &` can be obtained with [`std::addressof`](https://en.cppreference.com/w/cpp/memory/addressof)
10. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-arrowptr_14-0)** The return type of `operator->()` must be a type for which the `->` operation can be applied, such as a pointer type. If `x` is of type `C` where `C` overloads `operator->()`, `x->y` gets expanded to `x.operator->()->y`.
11. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-arrowstar_15-0)**
Meyers, Scott (October 1999), ["Implementing operator-\>\* for Smart Pointers"](http://aristeia.com/Papers/DDJ_Oct_1999.pdf) (PDF), *Dr. Dobb's Journal*, Aristeia
.
12. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-scopal_16-0)** Although a `::` punctuator exists in C as of C23, it is not used as a scope resolution operator.
13. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-ud-literal_17-0)** About [C++11 User-defined literals](http://en.cppreference.com/w/cpp/language/user_literal)
14. ^ [***a***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-0) [***b***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-1) [***c***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-2) [***d***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-3) [***e***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-4) [***f***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-5) [***g***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX11_18-6) since C++11
15. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sizeof_19-0)** The parentheses are not necessary when taking the size of a value, only when taking the size of a type. However, they are usually used regardless.\[*[citation needed](https://en.wikipedia.org/wiki/Wikipedia:Citation_needed "Wikipedia:Citation needed")*\]
16. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-alignof_20-0)** C++ defines `alignof` operator, whereas C defines `_Alignof` (C23 defines both). Both operators have the same semantics.
17. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-typeof_21-0)** since C23; not in standard C++
18. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-23)** Behaves like const\_cast/static\_cast/reinterpret\_cast. In the last two cases, the `auto` specifier is replaced with the type of the invented variable x declared with `auto x(a);` (which is never interpreted as a function declaration) or `auto x{a};`, respectively.
19. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-25)** For user-defined conversions, the return type implicitly and necessarily matches the operator name unless the type is inferred (e.g. `operator auto()`, `operator decltype(auto)()` etc.).
20. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-infer_26-0)** The type name can also be inferred (e.g `new auto`) if an initializer is provided.
21. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-infer2_27-0)** The array size can also be inferred if an initializer is provided.
22. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-sinceCXX26_28-0)** since C++26
- [Bitwise operations in C](https://en.wikipedia.org/wiki/Bitwise_operations_in_C "Bitwise operations in C") – Operations transforming individual bits of integral data types
- [Bit manipulation](https://en.wikipedia.org/wiki/Bit_manipulation "Bit manipulation") – Algorithmically modifying data below the word level
- [Logical operator](https://en.wikipedia.org/wiki/Logical_operator "Logical operator") – Symbol connecting formulas in logic
- [Boolean algebra (logic)](https://en.wikipedia.org/wiki/Boolean_algebra_\(logic\) "Boolean algebra (logic)") – Algebraic manipulation of "true" and "false"
- [Table of logic symbols](https://en.wikipedia.org/wiki/Table_of_logic_symbols "Table of logic symbols") – List of symbols used to express logical relations
1. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-3)**
["Operator overloading§Comparison operators"](https://en.cppreference.com/w/cpp/language/operators#Comparison_operators). *cppreference.com*.
2. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-6)**
["Standard C++"](https://isocpp.org/wiki/faq/operator-overloading).
3. ^ [***a***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-Integers_8-0) [***b***](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-Integers_8-1)
"Integers implementation", [*GCC 4.3.3*](https://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Integers-implementation.html#Integers-implementation), GNU
.
4. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-11)**
["ISO/IEC 9899:1999 specification, TC3"](https://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf#%5B%7B%22num%22%3A148%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C-27%2C816%2Cnull%5D) (PDF). p. 64, § 6.4.6 *Ponctuators* para. 3.
5. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-22)**
["user-defined conversion"](https://en.cppreference.com/w/cpp/language/cast_operator). Retrieved 5 April 2020.
6. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-24)** [Explicit type conversion](https://en.cppreference.com/w/cpp/language/explicit_cast) in C++
7. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-Committee_29-0)**
*ISO/IEC 14882:1998(E) Programming Language C++*. open-std.org – The C++ Standards Committee. 1 September 1998. pp. 40–41\.
8. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-30)**
*ISO/IEC 9899:201x Programming Languages - C*. open-std.org – The C Standards Committee. 19 December 2011. p. 465.
9. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-31)**
*the ISO C 1999 standard, section 6.5.6 note 71* (Technical report). ISO. 1999.
10. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-32)**
["C++ Built-in Operators, Precedence and Associativity"](https://docs.microsoft.com/en-US/cpp/cpp/cpp-built-in-operators-precedence-and-associativity). *docs.microsoft.com*. Retrieved 11 May 2020.
11. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-33)**
["C Operator Precedence - cppreference.com"](https://en.cppreference.com/w/c/language/operator_precedence). *en.cppreference.com*. Retrieved 10 April 2020.
12. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-34)**
["Does the C/C++ ternary operator actually have the same precedence as assignment operators?"](https://stackoverflow.com/questions/13515434/does-the-c-c-ternary-operator-actually-have-the-same-precedence-as-assignment/13515505). *Stack Overflow*. Retrieved 22 September 2019.
13. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-35)**
["Other operators - cppreference.com"](https://en.cppreference.com/w/c/language/operator_other). *en.cppreference.com*. Retrieved 10 April 2020.
14. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-36)**
["c++ - How does the Comma Operator work"](https://stackoverflow.com/questions/54142/how-does-the-comma-operator-work/). *Stack Overflow*. Retrieved 1 April 2020.
15. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-Bell_37-0)**
[*C history § Neonatal C*](https://www.bell-labs.com/usr/dmr/www/chist.html), Bell labs
.
16. **[^](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#cite_ref-38)**
["Re^10: next unless condition"](https://www.perlmonks.org/?node_id=1159769). *www.perlmonks.org*. Retrieved 23 March 2018.
- "Operators", [*C++ reference*](https://en.cppreference.com/w/cpp/language/expressions#Operators) (wiki)
.
- [C Operator Precedence](https://en.cppreference.com/w/c/language/operator_precedence)
- [*Postfix Increment and Decrement Operators: ++ and --*](https://docs.microsoft.com/en-US/cpp/cpp/postfix-increment-and-decrement-operators-increment-and-decrement) (Developer network), Microsoft, 17 August 2021
. |
| Shard | 152 (laksa) |
| Root Hash | 17790707453426894952 |
| Unparsed URL | org,wikipedia!en,/wiki/Operators_in_C_and_C%2B%2B s443 |