title: Fractions class in c++ explaination
body: <p>Can someone just explain whats going in this code? You don't have to go line by line but a general summary would be really helpful. It's similar to other fraction class c++ code so you don't have to completely refer to this code. </p>
  
  <pre><code>#include&lt;iostream&gt;
  
  using namespace std;
  
  class Fraction
  
  {
  
    private:
  
    int num, den;
  
    public:
  
    Fraction(int n = 1, int d = 2) : num(n), den(d) { }
  
    void show() { cout«num«”/”«den; }
  
    Fraction operator+(Fraction f) const
  
    { return Fraction(num+f.num, den+f.den); }
  
    Fraction operator-(Fraction f) const
  
    { return Fraction(num-f.num, den-f.den); }
  
    Fraction operator*(Fraction f) const
  
    { return Fraction(num*f.num, den*f.den); }
  
    Fraction operator/(Fraction f) const
  
    {
  
      int rNum = (f.den*num)/den;
  
      return (rNum, f.num);
  
     } 
  
    friend ostream&amp; operator«(ostream&amp; out, Fraction&amp; f)
  
    { cout«f.num«”/”«f.den; return out; }
  
    friend istream&amp; operator»(istream&amp; in, Fraction&amp; f)
  
    { cout«”\nEnter Numerator: “; cin»f.num; cout«”Enter Denominator: “;
  
      cin»f.den; cout«f.num«”/”«f.den; return in; }
  
    int ndMax()
  
    { return (num&lt;=den) ? num:den; }
  
    void reduce()
  
    {
  
    for(int i = 2; i&lt;=ndMax(); i++)
  
      if(num%i == 0 &amp;&amp; den%i == 0)
  
      { num = num/i; den = den/i; i = 1; }
  
    }
  
  }; // 
  
  int main()
  
  {
  
    Fraction f1(5, 6);
  
    Fraction f2(80, 1001);
  
    cout«f1«” and “«f2«endl;
  
    Fraction f3 = f1/f2;
  
    f3.reduce(); cout«f3;
  
    cout«endl;
  
    return 0;
  
   }
  </code></pre>