|
You have seen many instances of the usual operator tokens in C++:
+ - * / = ->&& new new[] delete delete[] etc.
When the arguments supplied to any of these and other operators are of class type, what the compiler actually invokes is an operator function that is associated with the operator token. For example, for the case of class type arguments, associated with the operator token ‘+’ is the following operator function
operator+
Similarly, associated with the operator token, or operator for short, ‘=’ is the operator function
operator=
and with the operator ‘<<,’ the operator function
operator<<
Overload definitions for operator functions come in two forms: Definitions that are global and definitions that are member functions for a class. When it is possible to provide overload definitions both ways, the overloaded operator works the same with either implementation.
|