Question: Continuation of the Class Rational program in C++. Here's the question and below that is the code #include public class Rational{ private : int numerator;//stores
Continuation of the Class Rational program in C++. Here's the question and below that is the code

#include
public class Rational{ private : int numerator;//stores numerator int denominator;//stores denominator int gcd(int n, int d);// euclid algorithm public : Rational();// default constructor Rational(int n);// single parameter cnstructor Rational(int n, int d); // two parametre constructor int getNum(); // returns numerator int getDeno(); // returns denominatoor // overloaded
}; Ratinal :: Rational(){ numerator = 0; denominator = 1; } Rational :: Rational(int n){ numerator = n; denominator = 1; } Rational :: Rational(int n, int d){ int g = gcd(n,d); numerator = n/g; denominator = d/g; } int Rational :: gcd( int n, int d){ int t; while(d != 0){ t = d; d = n % d; n = t; } return n; } int Rational :: getNum(){ return numerator; } int Rational :: getDeno(){ return denominator; }
Modify your daily5 project to add more functionality to your Rational class Overload the following operators as friend functions: Addition (+), subtraction(-), multiplication(*), and division(/) Each of these operations should evaluate as a Rational number in simplest form and should be able to operate on a Rational and an integer promoted to a Rational as either argument. Overload the following Boolean operators as friend functions: Less than, greater than, less than or equal, greater than or equal, equal and not equal Overload the pre and post version of the increment and decrement operators (++ and-. Although we did not do so in class these operators can both be overloaded and one is distinguished from the other by having an extra integer argument(that happens to be unused). Let me know in class if you need help with this one... Your program should be submitted with a suitable test program that demonstrates all of these operators in working order. Turn in your daily6.cpp file on Blackboard
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
