Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

=+free to pirate employees from competitors?

Answered: 1 week ago