title: C++ Rational Class
body: <p>So i have been working on this rational class function to calculate fractions and for some reason, something in the middle of the code is wrong and it just ends at simplified fractions. It is supposed to ask for either (+-*/) and then perform that operation on the given fraction. My code compiles with no errors, here it is:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  // Class Definitions
  
  class RationalNumber
  {
  public:
       RationalNumber(int, int, int, int);                    
       RationalNumber operator+(RationalNumber);
       RationalNumber operator-(RationalNumber);
       RationalNumber operator*(RationalNumber);
       RationalNumber operator/(RationalNumber);
       RationalNumber operator&lt;(RationalNumber);
       RationalNumber operator&gt;(RationalNumber);
       RationalNumber operator&lt;=(RationalNumber);
       RationalNumber operator&gt;=(RationalNumber);
       RationalNumber operator==(RationalNumber);
       RationalNumber operator!=(RationalNumber);
  private:
       int numerator;
       int denominator;
       int numerator2;
       int denominator2;
  
  };  // end RationalNumber class
  
  
  // RationalNumber class member-function definitions
  RationalNumber::RationalNumber(int num, int denom, int num2, int denom2)
  {
       numerator = num;
       denominator = denom;
       numerator2 = num2;
       denominator2 = denom2;
  
  //for first fraction
   if (denominator == 0 || denominator &lt; 0)
        cout &lt;&lt; "ERROR:Denominator can not be zero or less than zero." &lt;&lt; "\n";
  
   else
        //Reduces the fraction to lowest terms.
   {
        int i = numerator &gt; denominator ? numerator : denominator;
  
        while(i &gt; 1)
        {
             if(numerator % i == 0 &amp;&amp; denominator % i == 0)  
             {
             numerator /= i;
             denominator /= i;
             }
             --i;
        }
  
   }
  
   cout &lt;&lt; "Simplified fraction one is: " &lt;&lt; numerator &lt;&lt; " / "
      &lt;&lt; denominator &lt;&lt; "\n";
  
  //For second fraction
   if (denominator2 == 0 || denominator2 &lt; 0)
        cout &lt;&lt; "ERROR:Denominator can not be zero or less than zero" &lt;&lt; "\n";
   else
        //Reduces the fraction to lowest terms.
   {
        int j = numerator2 &gt; denominator2 ? numerator2 : denominator2;
  
        while(j &gt; 1)
        {
             if(numerator2 % j == 0 &amp;&amp; denominator2 % j == 0)  
             {
             numerator2 /= j;
             denominator2 /= j;
             }
             --j;
        }
  
   }
   cout &lt;&lt; "Simplified fraction two is: " &lt;&lt; numerator2 &lt;&lt; " / "
      &lt;&lt; denominator2 &lt;&lt; "\n";
  
  }
  
  // addition operator
  RationalNumber RationalNumber::operator+(RationalNumber a)
  {
        RationalNumber temp=RationalNumber(1,2,3,4);
        temp.numerator = numerator + a.numerator;
        temp.denominator = denominator + a.denominator;
        temp.numerator2 = numerator2 + a.numerator2;
        temp.denominator2 = denominator2 + a.denominator2;
        return temp;
  }
  
  // subtraction operator
  RationalNumber RationalNumber::operator-(RationalNumber a)
  {
        RationalNumber temp=RationalNumber(1,2,3,4);
        temp.numerator = numerator - a.numerator;
        temp.denominator = denominator - a.denominator;
        temp.numerator2 = numerator2 - a.numerator2;
        temp.denominator2 = denominator2 - a.denominator2;
        return temp;
  }
  
  // multiplication operator
  RationalNumber RationalNumber::operator*(RationalNumber a)
  {
        RationalNumber temp=RationalNumber(1,2,3,4);
        temp.numerator = numerator * a.numerator;
        temp.denominator = denominator * a.denominator;
        temp.numerator2 = numerator2 * a.numerator2;
        temp.denominator2 = denominator2 * a.denominator2;
        return temp;
  }
  
  // division operator
  RationalNumber RationalNumber::operator/(RationalNumber a)
  {
        RationalNumber temp=RationalNumber(1,2,3,4);
        temp.numerator = numerator / a.numerator;
        temp.denominator = denominator / a.denominator;
        temp.numerator2 = numerator2 / a.numerator2;
        temp.denominator2 = denominator2 / a.denominator2;
        return temp;
  }
  
  int main()
  {
  
       int top;
       int bot;
       int top2;
       int bot2;
  
       cout &lt;&lt; "Please enter the Numerator for fraction one: \n";
       cin &gt;&gt; top;
       cout &lt;&lt; "Please enter the Denominator for fraction one: \n";
       cin &gt;&gt; bot;
       cout &lt;&lt; "Please enter the Numerator for fraction two: \n";
       cin &gt;&gt; top2;
       cout &lt;&lt; "Please enter the Denominator for fraction two: \n";
       cin &gt;&gt; bot2;
  
       RationalNumber A(top, bot, top2, bot2);
       return 0;
  
  }
  </code></pre>
  
  <p>I have scanned my code many times and cannot find the place where it is halting the operation. Maybe a new set of eyes can shed some light on this very annoying situation. Thanks</p>