Question: Enhance the class Rational by filling out the class interface provided below and implementing additional overloaded binary operators as listed. Also use the C +

Enhance the class Rational by filling out the class interface provided below and implementing additional overloaded binary operators as listed. Also use the C++ exception-handling feature to ensure a valid rational number is used when a Rational object is instantiated. Check your code against the Rational class test provided, and only submit your Rational.cc file.
class Rational {
friend std::ostream& operator<<(std::ostream&, const Rational&);
public:
Rational(): numerator(), denominator(1){}
Rational(int, int); // Constructor now validates object
void reduce();
void set_number(int, int);
Rational operator+(const Rational&) const; // Addition
// Subtraction
// Multiplication
// Division
// Less-than
// Greater-than
// Equal-to
// Not-equal-to
private:
int numerator;
int denominator;
};

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 Databases Questions!