Week 4 Introduction Note that the links from this page are to handouts that will be distributed the night of class. Only print out those handouts if you could not attend class. Should do what makes sense for the class. In general, anytime you use an operator with a class, the compiler generates a function call to the appropriate overloaded operator function. When the left side of the operator is not an instance of the class, you use a non-member function.
Friend functions solve the problem.
Use class member functions for overloading operators if the left hand side of the operators is an instance of the class. Use non-member friend functions for overloading operators only if the left hand side of the operator is not an instance of the class. Here's a handout that lists the most commonly overloaded operators and how you would declare them in a class. In CS II you will have to write your own classes. This handout has some tips on good class design.