Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions