Namespaces
Variants
Views
Actions

Other operators

From cppreference.com
< cpp‎ | language
Revision as of 08:57, 25 April 2011 by WikiSysop (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:cpp/language/sidebar

Operator name Syntax Over​load​able Prototype examples (for Template:cpp)
Inside class definition Outside class definition
function call a(a1, a2) Yes Template:cpp N/A
comma a, b Yes Template:cpp Template:cpp
conversion (type) a Yes Template:cpp N/A
ternary conditional a ? b : c No N/A N/A

Explanation

function call operator provides function semantics for any object.

conversion operator converts given type to another type. The name of the operator must be the same as the type intended to be returned.

ternary conditional operator checks the boolean value of the first expression and replaces entire operator clause with the second or the third expression depending on the resulting value. For example, Template:cpp is equivalent to Template:cpp

See also

Operator precedence

Common operators
assignment increment
decrement
arithmetic logical comparison member
access
other

a = b
a += b
a -= b
a *= b
a /= b
a %= b
a &= b
a |= b
a ^= b
a <<= b
a >>= b

++a
--a
a++
a--

+a
-a
a + b
a - b
a * b
a / b
a % b
~a
a & b
a | b
a ^ b
a << b
a >> b

!a
a && b
a || b

a == b
a != b
a < b
a > b
a <= b
a >= b
a <=> b

a[...]
*a
&a
a->b
a.b
a->*b
a.*b

function call
a(...)
comma
a, b
conditional
a ? b : c
Special operators

static_cast converts one type to another related type
dynamic_cast converts within inheritance hierarchies
const_cast adds or removes cv-qualifiers
reinterpret_cast converts type to unrelated type
C-style cast converts one type to another by a mix of static_cast, const_cast, and reinterpret_cast
new creates objects with dynamic storage duration
delete destructs objects previously created by the new expression and releases obtained memory area
sizeof queries the size of a type
sizeof... queries the size of a parameter pack (since C++11)
typeid queries the type information of a type
noexcept checks if an expression can throw an exception (since C++11)
alignof queries alignment requirements of a type (since C++11)