Intermediate Business Programming with C++
Define a class called fractions i.e. it is a class of numbers of the form: a/b where a and b are longs and where b can not be 0. Require that each fraction as soon as it enters the program is in reduced format. i.e. the greatest common divisor of a and b must be 1 after entry into the program. Overload the insertion and extraction operators: << and >> on the class objects. Overload the operators: +, -, * and / on the objects of fractions. Make the definition of the class fractions and their operations as robust as possible by using exception theory so that no fractions are permitted that would have the value of b equal to 0.
For a solution to these specifications check the following program: fractions.cpp
Категории