can U plz explain this Q for me, i do not know how to solve it ?

Rational fractions are of the form a / b, where a and b are integers and b ≠ 0. In this assignment, by "fractions" we mean rational fractions. Suppose a / b and c / d are fractions. Arithmetic operations on fractions are defined by the following rules:
a/b + c/d = (ad + bc)/bd
a/b - c/d = (ad - bc)/bd
Fractions are compared as follows: a / b op c / d if ad op cd, where op is any of the relational operations. For example, a/b < c/d if ad<bc.
Design a class—say, fractionType—that performs the arithmetic and relational operations +, -, > and < on fractions. Overload the arithmetic and relational operators so that the appropriate symbols can be used to perform the operation.

Write a C++ program that, using the class fractionType, performs operations on fractions.

Write out the class declaration (i.e., what you would put in the header file, class fractionType{//your declarations here }; ) and pinpoint specific areas that are giving you trouble. Try it on your own first, then search around in this forum for "rational class","fraction class", "operator overloading fraction."

you need some readings on core C++ language book.
read the chapter "Operator Overloading" .

and tip here , you're constructor for the class going to be look like this.

class FractionType
  int a , b ;
            // constructor
            // FractionType a/b where a and b are inputs.
             FractionType( int a_ , int b_ ) a(a_) , b (b_) ; 

          // overload the operators here.
          // ......

First thing is find out a good free book or tutorial and read that operator overloading chapter completely and do it's particles.and
after that ask the questions on you're mind regarding this problem.

good luck.

Edited 7 Years Ago by NicAx64: n/a

This article has been dead for over six months. Start a new discussion instead.