DUE: Sunday 4/17, 11 pm (no late turn-in)
class Rational
{
public:
Rational();
Rational(int num, int den);
void display_fract() const;
int get_num() const;
int get_den() const;
private:
int numerator;
int denominator;
};
In all cases, you must give an example of how the function is to be used in an application.Rational test_fraction(7, 13); //declares & initializes a Rational called test_fraction to 7/13 display(test_fraction); //outputs 7/13 to the console
Rational sum_fracts(Rational lhs_fract, Rational rhs_fract);
Rational add_fract(Rational rhs_fract);Remember that the sum of two fractions n1/d1 and n2/d2 is given by (n1*d2 + n2*d1) / d1*d2
Rational operator +(Rational rhs_fract);
The function definition header is:
Rational::Rational operator +(Rational rhs_fract)
{
// function definition
}
Note that, since this is a member function, we only supply one explicit parameter,
the right-hand-side; the implicit parameter provides the left-hand-side fraction.
The function will be invoked in an application as follows:
Rational f1, f2;
Rational sum;
//some code that sets the values of f1 and f2
sum = f1 + f2;
//f1 is the implicit parameter, f2 is the explicit parameter.