Question: How to solve problem with c++? A class called Fraction consists of private variables int numerator and int denominator. The Fraction class has a member

 How to solve problem with c++? A class called Fraction consists

How to solve problem with c++?

A class called Fraction consists of private variables int numerator and int denominator. The Fraction class has a member function called get value) that takes no arguments and returns a double. It has regular and default constructors. It also has an operator member function + that takes as an argument another Fraction object and returns a Fraction object Here is an example of how the class might be used in a program: Fraction A(5,3); // numerator set to 5 denominator set to 3 Fraction B(1,7); // numerator set to 1 denominator set to 7 Fraction C; // default constructor used, numerator set to 0 // denominator set to 1 int value = A.get-value(); // value is 5/3 CA B; // C becomes the sum of fractions A and B // This means that the numerator of C is 5*7+3*1 // and the denominator of C is 3*7 a) Write the class declaration for the Fraction class. b) Write the definitions of the regular constructor and the default constructor. Refer to the exampleabove to see how these work c) Write the definition for the member function get_value(). This functior returns the decimal value of the Fraction object (the numerator divided by the denominator). d) Write the definition of the operator +. Write this function so that the expression CA B; in the example above makes sense. The numerator of C should be given by the formula: numerator cdenominator b * numerator a denominator a * numerator b The denominator is given by: numerator c denominator a * denominator b

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!