Question: Problem Create a class named Fraction containing two integer data members named num and denom used to store the numerator and denominator of a fraction
Problem
Create a class named Fraction containing two integer data members named num and denom used to store the numerator and denominator of a fraction having the form num/denom.
Specification
1. Include default and parametrized constructors.
The default constructor should initialize num and denom to 1.
Neither constructor should allow a 0 denominator value.
2. Overload operator functions for
addition +: a/b + c/d = (a * d + b * c) / (b * d)
subtraction -: a/b - c/d = (a * d - b * c) / (b * d)
multiplication *: a/b * c/d = (a * c) / (b * d)
division /: a/b / c/d = (a * d) / (b * c)
stream insertion: << to send a fraction to the screen.
stream extraction: >> to input a fraction from the keyboard.
3. Include the class in a C++ program that tests each member function.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
