Other operators
From Cppreference
Operator name | Syntax | Overloadable | Prototype examples (for class T) | |
---|---|---|---|---|
Inside class definition | Outside class definition | |||
function call | a(a1, a2) | Yes | R T::operator()(Arg1 &a1, Arg2 &a2, ... ...); | N/A |
comma | a, b | Yes | T2& T::operator,(T2 &b); | T2& operator,(const T &a, T2 &b); |
conversion | (type) a | Yes | operator type() | N/A |
ternary conditional | a ? b : c | No | N/A | N/A |
[edit] 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, {{{1}}} is equivalent to {{{1}}}
[edit] See also
Common operators | ||||||
---|---|---|---|---|---|---|
assignment | increment decrement |
arithmetic | logical | comparison | member access |
other |
a = b a = rvalue |
++a --a |
+a -a |
!a a && b |
a == b a != b |
a[b] *a |
a(...) a, b |
Special operators | ||||||
static_cast converts one type to another compatible type |