Question: Operator Overloading Problems, Augment the code below to answer in c++ #include #include #include using namespace std; class RationalNumber { public: RationalNumber(): RationalNumber(0, 1) {

Operator Overloading Problems, Augment the code below to answer in c++

#include #include #include using namespace std;

class RationalNumber { public: RationalNumber(): RationalNumber(0, 1) { } RationalNumber(int n): RationalNumber(n, 1) { } RationalNumber(int n, int d); int getNumerator() const { return numerator; } int getDenominator() const { return denominator; } void setNumerator(int n) { numerator = n; } void setDenominator(int d) { denominator = d;}

static int gcd(int a, int b); static int lcm(int a, int b); void reduce();

void output() const { cout

RationalNumber::RationalNumber(int n, int d) { if(d == 0) { cout

int temp; while(b != 0) { temp = a; a = b; b = temp%b; } return a; }

int RationalNumber::lcm(int a, int b) {

return (a*b)/gcd(a, b); }

void RationalNumber::reduce() {

int x = gcd(numerator, denominator); numerator = numerator/x; denominator = denominator/x; }

int main() { RationalNumber r1{12, 18}; cout

Operator Overloading Problems, Augment the code below to answer in c++ #include

8. Augment the code in problem 7. a. Overload the and operators. b. Verify both functions are working properly. 9. Augment the code in problem 8. a. Overload the ,!-, >, > (extraction) operators b. Verify that all functions are working properly. 11. Augment the code in problem 10 a. Overload the [ (bracket) operator. b. Verify that all functions are working properly

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!