Homework 6

Write a class of imaginary numbers. This class should have a double which holds the value, and a bool i which indicates if the number is or is not imaginary (imaginary numbers are simply the double multiplied times the square root of -1). Overload the operators used in the calculator. Overload the << operator. Write a string_to_imaginary function.

Write templatized stack and node classes. Change the interface of your calculator to allow the user to choose the type of calculator they want. Allow the user to choose double (a regular old friendly double), rational, or imaginary numbers. Create only one stack of the apropriate type. Do not have separate switch statements based on the type of the stack. Find a way to detect a number or operator being input for any class (ie, look at the first character entered by the user before doing conversion), and proceed from there. Your main function should have a minimal number of additional lines than in your ORIGINAL calculator code.