I am having a difficult time figuring out how to overload the addition '+' operator to add two fractions from my Fraction Class.

I've searched this site and pored over several books only to find nothing pertaining to my delimma.

Obviously, this is a school assignment and this is for class credit. I would like to further UNDERSTAND the concept of operator overloading and am not asking for someone to write this for me, however, I would greatly appreciate ANY and ALL suggestions concerning this.

I've got everything else in place (or so I believe). This is ticking me off, considering that the next thing I have to do is overload many more operators. Thank you.Code:#include <iostream> #include <iomanip> using namespace std; #include <stdlib.h> class Fraction { private: int WholeNumber; int Numerator; int Denominator; public: Fraction() { WholeNumber = 0; Numerator = 0; Denominator = 1; } Fraction(int w, int n, int d): WholeNumber(w), Numerator(n), Denominator(d) {} Fraction(const Fraction & rhs) { WholeNumber = rhs.getWholeNumber(); Numerator = rhs.getNumerator(); Denominator = rhs.getDenominator(); } int getWholeNumber(void) const { return WholeNumber; } //provide definition here... int getNumerator(void) const { return Numerator; } int getDenominator(void) const { return Denominator; } void getFraction(void) const { cout << WholeNumber; if(Numerator) cout << " " << Numerator << "/" << Denominator; } void setFraction(int w, int n, int d) { int fract = (w * n + d)/ d; //WholeNumber * Denominator + Numerator } void setFraction(void) { char Temp[] = " "; char *pChr; char w[8], n[8], d[8]; for(int count = 0; count < 7; count++) { w[count] = ' '; n[count] = ' '; d[count] = ' '; } d[count] = '\0'; n[count] = '\0'; w[count] = '\0'; pChr = &Temp[15]; cin.getline(Temp,15); while(*pChr == ' ') { pChr--; } *pChr = '\0'; int NullLocation = (pChr - Temp); pChr--; char *pDen = &d[6]; char *pNum = &n[6]; char *pWhole = &w[6]; for(count = 0; count < NullLocation; count++) { if(Temp[count] == '/') break; } if(count >= NullLocation) { Denominator = 1; Numerator = 0; } else { while(*pChr != '/') { *pDen = *pChr; pDen--; pChr--; } Denominator = atoi(d); pChr--; while(*pChr != ' ') { *pNum = *pChr; pNum--; pChr--; } Numerator = atoi(n); }//End else while(pChr >= &Temp[0]) { *pWhole = *pChr; pWhole--; pChr--; } WholeNumber = atoi(w); } void AddFractions(Fraction, Fraction); void ReduceFractions(void); Fraction Fraction::operator + (Fraction & rhs); }; void Fraction::AddFractions(Fraction One, Fraction Two) { int New1; int New2; int NewNumerator, CarryOut; WholeNumber = One.WholeNumber + Two.WholeNumber; Denominator = One.Denominator + Two.Denominator; New1 = One.Numerator * Two.Denominator; New2 = Two.Numerator * One.Denominator; NewNumerator = New1 + New2; CarryOut = NewNumerator / Denominator; WholeNumber += CarryOut; Numerator = NewNumerator % Denominator; } void Fraction::ReduceFractions(void) { int First = Numerator; int Second = Denominator; int Temp; if(Numerator ==0) { Denominator = 1; return; } while(First != Second) { if(First < Second) { Temp = First; First = Second; Second = Temp; } First -= Second; } Numerator /= First; Denominator /= First; } int main(void) { Fraction FirstOne; Fraction SecondOne; Fraction Sum; cout << "Enter the first fraction value: " << endl; FirstOne.setFraction(); cout << "Enter the second fraction value: " << endl; SecondOne.getFraction(); Sum.AddFractions(FirstOne, SecondOne); Sum.ReduceFractions(); cout << endl << "The sum of "; FirstOne.getFraction(); cout << " and "; SecondOne.getFraction(); cout << " is "; Sum.getFraction(); cout << endl << endl; Fraction NewSum = FirstOne + SecondOne; cout << endl << "The sum of "; FirstOne.getFraction(); cout << " and "; SecondOne.getFraction(); cout << " is "; Sum.getFraction(); cout << endl << endl; return 0; } Fraction::operator +(Fraction &fract) { Fraction temp; temp = Fraction(WholeNumber * Denominator + Numerator) + (fract.getWholeNumber() * fract.getDenominator() + fract.getNumerator(); return Fraction::setFraction(temp); }