Question: Define the class Rational with the following data members: numerator, denominator (of type integer). The class also has the member functions set( ), get( ),


Define the class Rational with the following data members: numerator, denominator (of type integer). The class also has the member functions set( ), get( ), and a default parameterized constructor. Overload: 1. *, ==, post-increment rational number operations as members of the class Rational 2. +, pre-increment rational number operations, the insertion operator and the extraction operator as nonmember functions of the class Rational. Use the following rules.



// Rational.cpp

#include \"Rational.h\"

int main() { Rational rOne, rTwo; Rational rSum, rMul;

cin >> rOne >> rTwo;

cout cout

rSum = rOne + rTwo; cout

rMul = rOne * rTwo; cout

cout

cout

if(rOne == rTwo) cout else cout

return 0; }




Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!