operator [C++ Reference]
Keywords: keywords,operator
Date: 2008-10-14T15:42:04-0700

[[operator]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## operator

Syntax:

        return-type class-name::operator#(parameter-list) {
        ...
        }
        return-type operator#(parameter-list) {
        ...
        }

The operator keyword is used to overload operators. The sharp sign (#) listed above in the syntax description represents the operator which will be overloaded. If part of a class, the class-name should be specified. For unary operators, parameter-list should be empty, and for binary operators, parameter- list should contain the operand on the right side of the operator (the operand on the left side is passed as this). For the non-member operator overload function, the operand on the left side should be passed as the first parameter and the operand on the right side should be passed as the second parameter. You cannot overload the #, ##, ., :, .*, or ? tokens.

Related Topics: this

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •