Other operators
Operator name | Syntax | Overloadable | 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
Common operators | ||||||
---|---|---|---|---|---|---|
assignment | increment decrement |
arithmetic | logical | comparison | member access |
other |
a = b |
++a |
+a |
!a |
a == b |
a[...] |
function call |
a(...) | ||||||
comma | ||||||
a, b | ||||||
conditional | ||||||
a ? b : c | ||||||
Special operators | ||||||
static_cast converts one type to another related type |