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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started