I have an assignment of the following.

Create a class named Fractions having two integer data members named for a fraction’s numerator and denominator. The Class’s default constructor should provide both data members with default values of 1 if no explicit user initialization is provided. The constructor must also prohibit a 0 denominator value. Additionally, provide member functions for displaying an object’s data values. Also provide the class with overloaded operators that are capable of adding, subtracting, multiplying and dividing two Fraction objects according to the following formulas:

Sum of two fractions: a/b + c/d = ad + cb
--------
bd
Difference of two fractions: a/b – c/d = ad – cb
______
bd

Product of two fractions a/b X c/d = ac
---
bd
Division of two fractions: a/b / c/d = ad
---
bc


To be fairly honest with you, I don't even know where to begin on this. I will toy with it and post what I have and hope you guys can help me.

Thank you

class Fractions
{

public:

     //class constructor
     Fractions( );

     //overloaded operators
     Fraction operator+(const Fraction &rhs);
     Fraction operator-(const Fraction &rhs);
     Fraction operator/(const Fraction &rhs);
     Fraction operator*(const Fraction &rhs);

     //other 
     void print( );

private:

     int numerator;
     int denominator;
}

This is about all the help I can give ye' for now.. Above is an example class that should get you started.. all you have to do is write the functions. :cool:

Thank you for your help. I should be good with it now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.