8.8. Exercises
- 1. What would happen if we compiled the program in Figure 8.37? Why?
- 2. What would happen if we compiled the program in Figure 8.38? Why?
- 3. We have already implemented operator < and operator ==. However, a concrete data type that allows for ordered comparisons such as < should really implement all six of the comparison operators. The other four of these operators are >, >=, <=, and != ("greater than", "greater than or equal to", "less than or equal to", and "not equal to", respectively). Add the declarations of each of these operators to the string interface definition.
- 4. Implement the four comparison operators that you declared in the previous exercise.
- 5. Write a test program to verify that all of the comparison operators work. This program should test that each of the operators returns the value true when its condition is true; equally important, it should test that each of the operators returns the value false when the condition is not true.
|
www.steveheller.com steve@steveheller.com |