You can overload a binary operator by declaring a nonmember function taking two arguments or a nonstatic member function taking one argument.
When you use a class object with an overloaded binary
operator, for example:
class X { // ... }; void main () { X x; int y=10; x*y; // overloaded binary operator }
the operator function call x*y can be interpreted as: x.operator*(y) or operator*(x,y) depending on the declarations of the operator function. If both forms of the operator function have been declared, argument matching determines which interpretation is used.
Overloading Unary Operators
Overloading Operators
Special Overloaded Operators
Restrictions on Overloaded Operators