title: Ive been getting a error: "in function main: undefined reference to Fraction::Fraction()"
body: <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class Fraction
  {
  
  private:
    //variables to store numerator and denominator
    int num;
    int denom;
  
  public:
    Fraction();
    Fraction(int num): num(num) {}
    Fraction(int num, int denom): num(num), denom(denom) {}
  
    int get_numerator() const {return num;}
    int get_denominator() const {return denom;}
  };
  
  istream &amp;operator&gt;&gt; (istream &amp;input, Fraction &amp;f)
  {
    int n, d;
    char slash;
    input &gt;&gt; n;
    input &gt;&gt; slash;
    input &gt;&gt; d;
  
    f = Fraction(n, d);
    return input;
  }
  
  ostream &amp;operator&lt;&lt;(ostream &amp;output, const Fraction &amp;frac)
  {
    return output &lt;&lt; frac.get_numerator() &lt;&lt; "/" &lt;&lt; frac.get_denominator();
  }
  
  int main()
  {
    Fraction frac(1,2);
    Fraction frac2;
  
    cout &lt;&lt; frac &lt;&lt; endl;
  
    cin &gt;&gt; frac2;
    cout &lt;&lt; frac2 &lt;&lt; endl;
  
    return 0;
  }
  </code></pre>
  
  <p>I am trying to create a fraction data type.
  The code should allow the user to input a fraction using the overloaded ">>" operator but it does not work as i get an error:
  in function 'main' : undefined reference to Fraction::Fraction()</p>
  
  <p>Ive tried the code without the overloaded input operator and it works fine.</p>
  
  <p>What am i doing wrong? </p>