CS12, Lab 7

Week of February 18--22

 

 

Topics: 

·        Function Templates

 

 

 

To do: 

·        (This is problem 12.6 on page 721).

·        Write a simple function template for a function isEqualTo() that takes two arguments and compares them using the equality operator (==). The function returns true if the arguments are equal and false if they are not.

·        Use this function template in a program that calls isEqualTo() with a variety built-in types (int, double, char).

·        Now write a version of the program that calls isEqualTo() with two Counter objects. Since the Counter class does not overload the == operator, what happens when you attempt to compile and run this program?

·        Overload the == operator in the counter class (with the function operator==). What happens when you attempt to compile and run the program now?