Name
operator keyword — Function call syntax for operators
Synopsis
operator-function-id ::= operator op-symbol | operator op-symbol < [template-arg-list] > conversion-function-id ::= operator conversion-type-id conversion-type-id ::= type-specifier-seq [conversion-declarator] conversion-declarator ::= ptr-operator [conversion-declarator] ptr-operator ::= * [cv-qualifier-seq] | & | [::] nested-name :: * [cv-qualifier-seq]
The operator
keyword converts
an operator symbol into function notation. You can use the operator
keyword when invoking an operator
or when overloading an operator.
Example
int x =operator
+(10, 32); complex<double> c, d; c.operator
+=(d); operator+=(c, d); // Same as above bigintoperator
*(const bigint& a, const bigint* b);
Table 12-1 lists the operator symbols (op-symbol) that can be overloaded. Alternative tokens (shown in parentheses) are interchangeable with their symbolic equivalents.
| | | | | |
| | | | | |
| | | | | , |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
See Also
expression, identifier, template
, type, Chapter
5
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.