Question: Advanced C++ Problem: Fraction Object with Operator Overloads Overview: In this assignment, the student will write a C++ program that implements a fraction object. When

Advanced C++ Problem:

Fraction Object with Operator Overloads

Overview:

In this assignment, the student will write a C++ program that implements a fraction object. When writing the object, the student will demonstrate mastery of implementing overloaded operators in a meaningful way for the object.

Assignment Instructions:

Write a C++ object that implements a fraction object. In more precise terms, your object will contain the data needed to represent a rational expression. In mathematics, it is understood that all of the real numbers can be defined as the quotient of two integer values. Your fraction object should contain attributes that represent these two integers. When implementing your fraction object, you should minimally include the following components:

* You should provide a constructor method that initialized the rational expression to (0/1).

* You should provide a constructor method that allows client code to manually set integer values for the numerator and denominator.

* Your object should restrict mutation of itself so only valid rational expressions exist within the object (i.e. a value of 4/0 should be rejected).

* Your object should contain a series of getter and setter methods that allow safe mutation of the numerator and denominator.

* Your getter and setter methods must contain meaningful interfaces that communicate whether values were effectively modified by client code requests through return values. The driver code you write to demonstrate the object should also demonstrate these interfaces.

* Your object should contain overloaded binary arithmetic operators for addition, subtraction, multiplication, and division.

* Your object should always reduce the value represented by the contained rational expression to its lowest terms.

* Your object should contain a binary external operator overload for the stream insertion (<<) operator.

* Your driver code should instantiate a few instances of fractions and demonstrate all the arithmetic operations and displaying the objects information on the console with overloaded behavior when interacting

with cout (i.e. Your driver should have a statement resembling: cout << myFractionObject .

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!