We're going to begin the discussion of 
overloading operators. You're familiar with the 
operators, they're symbols. And what are they?
They're functions, actually. For your user-defined 
types, you're going to be able to now define these 
symbol
operations like multiplication and etc, etc. So, let's 
see how this works. Okay, for number one, let's 
discuss just what an operator is.
An operator is a function and it's a different kind of 
function. It's a symbol. We usually talk about 
functions as having parameters to which we pass
arguments and operators as having parameters 
to which we pass operands. Well, they're the 
same thing, operators and arguments are the
same. The difference between a function and an 
operator is that the name of an operator is 
"operator"
and then the symbol. In C++, operator is a key 
word, and that becomes part of the name of that 
function. So, it's going to be operator
and then whatever symbol. For instance 
operator*, operator+, operator less than less 
than. Whatever it is. And of course operators
are going to be called differently from the way 
functions are called and we're going to take a look 
at some examples.
We speak of operator overloading because all 
operators have already been defined for the built 
in C++ types. You cannot create new operators.
So, if you can't create new ones,
then the old ones have to be redefined, and 
hence you're overloading that operator. Of course 
you can define operators as either members of a
class or nonmembers of a class. And, remember 
that when we are defining an operator, we're 
defining
it for a user-defined type. In other words, a new 
class of objects.
So that function can either be defined outside the 
class or it can be defined inside the class.
So, let's take a look at some examples of calls. 
Here's a binary operator, I just chose star as an 
example, you use it as
'var1' times 'var2'. A binary operator, it has two 
operands or two parameters.
Okay, so 'var1' is the left-hand-side operand and 
'var2' is the right-hand-side operand. If this 
function, if this operator '*', and I'm going to refer
to the functions, the operators, as "operator * ()".
This is the way I'll refer to that function. If it's a 
nonmember function then 'var1' and 'var2' are 
arguments you pass to the parameters, but if it is
a member function, then 'var1' is the calling 
object and 'var2' is passed to the parameter. And 
remember
that every member function has a calling object. It 
is something that you want to really, really 
remember. Every member
function has a calling object. Some object of that 
class has to call that
function. If you always remember that, that'll help 
you a lot. Now, let's take a look at a unary 
operator.
A unary operator has one argument, or one 
operand. So, I've chosen the ~ operator as
an example. And the way you use that is, you 
have the symbol,
the ~ in this case, juxtaposed to the operand that 
you're going to operate on. But, the symbol 
comes before
that operand. So, 'var1' is the only operand. If that 
function,
that operator ~, is a nonmember function, then 
'var1' is what is passed to the parameter. And
if it's a member function, then 'var1' is the calling 
object.
So, let's review, real quickly, for binary operators.
If it's defined as a nonmember, it's going to have 
two parameters.
If it's a member, then what? Well, there are two 
operands, but one has to be the calling object so 
there's only one parameter.
One operand, the one on the left, is the calling 
object and one on the right fills the single 
parameter.
But for a unary operator, if it's in nonmember 
function, yes it will have one parameter and the 
operand and that it's operating on is passed
to that parameter. But if it is a member function, 
then it has no parameters, because the one and 
only operand has to be the calling object.
Always remember the calling object.
Let's review, real quickly, what some of the 
operators are. Okay, the first ones you saw were 
the insertion/extraction operators,
and yes you can overload those. And yes, that 
means it's a binary operator.
That means that "cin" is an operand and 'var' is 
