Fraction calculator assignment

computer science

Description

Here's my code so far. I am having trouble with compilation errors. I need to separate this into a Fraction.h and a Fraction.cpp

class Fraction{

public:

    Fraction()
        : num(0), den(1) {};
        : num(n), den(d) {};
    int getNum() const {
        return num;
    }
    int getDen() const {
        return den;
    }
    void setNum(int n){
         num = n;
    }
    void setDen(int d){
         den = d;
    }
   //overload the stream insertion and extraction operators.
   friend ostream& operator <<(ostream&, const Fraction &);
   friend istream& operator >> (istream&, Fraction &);
   //   overload the arithmetic operators
   Fraction operator+( const Fraction & );
   Fraction operator-( const Fraction & );
   private:
    int num;
    int den;
};
                  ( const Fraction & rightFraction )
{
   Fraction temp;
   temp.den = den * rightFraction.den;
}   //   end function operator+
{
   Fraction temp;
   temp.den = den * rightFraction.den;
}   //   end function operator-
ostream& operator<<( ostream& osObject,
const Fraction & myFraction )
{
   osObject << myFraction.num << "/" << myFraction.den;
   return osObject;
}   //   end function operator<<
istream& operator>>( istream& isObject, Fraction & myFraction)
{
   char ch;
   cout<<"Enter numerator:";
   isObject >> myFraction.num;
   cout<<"Enter denomerator:";
       isObject>> myFraction.den;
   return isObject;
}   

    Fraction( int n, int d)

Fraction Fraction ::operator+

   temp.num = ( num * rightFraction.den ) + ( den * rightFraction.num );

   return temp;

Fraction Fraction ::operator-( const Fraction & rightFraction )

   temp.num = ( num * rightFraction.den ) - ( den * rightFraction.num );

   return temp;

//   Overlod the stream extraction operator <<

//   Overload the stream extraction operator >>


Related Questions in computer science category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.