If the following class, Foo
, is defined. It is said it overloads the unary ampersand (&
) operator:
class Fo
Consider the following code:
int x;
Foo y;
&x; // built-in functionality
&y; // y.operator&();
We have two variables of different types. We apply the same &
operator to both of them. For x
it uses the built-in address-of operator whereas for y
it calls your user-defined function.
That's exactly what you're describing as overloading: There are multiple functions (well, one of them is the built-in functionality, not really a "function") and they're selected based on the type of the operand.