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