Providing an additional definition for an operator. It is declared using the keyword operator followed by the symbol for the operator being overloaded.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
Operator Overloading Rules
A
Binary operators can be defined by either having a member function take one argument or a global function taking two arguments.
For any binary operator @, a@b can be interpreted as a.operator@(b) or operator@(a, b).
Unary operators can be defined by either a member function taking no arguments or a global function takin gone argument.
For any unary operator @, @a can be interpreted as a.operator@() or operator@(a).
For any postfix unary operator @, a@ can be interpreted as a.operator@(int) or operator@(a, int)