Description
Final lab!
Exercise 1 of 3-
Write the generic class arrayType to define arrays that can check legal boundaries when accessing their elements. You can look at the main() method of the program to see how to use the class arrayType. Use templates and operator overloading in defining the class arrayType. The main function of the program is lab8_q1_main.cpp
Exercise 2 of 3-
Write a generic swapArgs() function that takes two inputs of various types and swaps their values. Specialize the swapArgs() function for the int data type, which causes the function to print “the inputs are of type int” as well.
Exercise 3 of 3-
Derive two classes, kiloToGrams and farenToCelsius, from the abstract class convertClass. These two classes convert kilogram to grams and Fahrenheit to Celsius, respectively.
The base class convertClass has two fields initialValue and convertedValue, which store the initial and converted values of the measurements. Two methods getInitial() and getConverted() of the convertClass class are getter methods. The compute() method of the convertClass performs the conversion of measurements, but it is a pure abstract method that any derived class must implement. The main() method of this question is Q3_main().
Discuss lines 15,16,22 and 23 of the main() method with TAs. Every derived class defines its required compute() method because it is a pure abstract method in the abstract class convertClass.
Reviews
There are no reviews yet.