title: Undefined reference to operator >>
body: <p>I am trying to work on operator overloading, my header file consists of: </p>
  
  <pre><code>#ifndef PHONENUMBER_H
  #define PHONENUMBER_H
  
  #include&lt;iostream&gt;
  #include&lt;string&gt;
  using namespace std;
  
  class Phonenumber
  {
      friend ostream &amp;operator &lt;&lt; ( ostream&amp;, const Phonenumber &amp; );
      friend istream &amp;operator &gt;&gt; ( istream&amp;, Phonenumber &amp; );
  private:
      string areaCode;
      string exchange;
      string line;
  
  };
  
  #endif // PHONENUMBER_H
  </code></pre>
  
  <p>And class definition of</p>
  
  <pre><code>//overload stream insertion and extraction operators
  //for class Phonenumber
  #include &lt;iomanip&gt;
  #include "Phonenumber.h"
  using namespace std;
  //overloades stram insertion operator cannot be a member function
  // if we would like to invoke it with
  //cout&lt;&lt;somePhonenumber
  ostream &amp;operator &lt;&lt; ( ostream &amp;output, const Phonenumber &amp;number)
  {
  
      output&lt;&lt;"("&lt;&lt;number.areaCode&lt;&lt;")"
       &lt;&lt;number.exchange&lt;&lt;"-"&lt;&lt;number.line;
      return output;
  
  }//end function opertaor &lt;&lt;
  
  istream &amp;operator &gt;&gt; ( istream &amp;input, Phonenumber &amp;number)
  {
      input.ignore(); //skip (
      input&gt;&gt;setw(3)&gt;&gt;number.areaCode;//input areacode
      input.ignore(2);//skip ) and space
      input&gt;&gt;setw(3)&gt;&gt;number.exchange;//input exchange
      input.ignore();//skip -
      input&gt;&gt;setw(4)&gt;&gt;number.line;//input line
      return input;
  }
  </code></pre>
  
  <p>calling done through main is</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include"Phonenumber.h"
  using namespace std;
  
  int main()
  {
      Phonenumber phone;
      cout&lt;&lt;"Enter number in the form (123) 456-7890:"&lt;&lt;endl;
      //cin&gt;&gt; phone invokes operator &gt;&gt; by implicitly issuing the non-member function call operator&gt;&gt;(cin,phone)
      cin &gt;&gt; phone;
      //cout&lt;&lt; phone invokes operator &lt;&lt; by implicitly issuing the non-member function call operator&gt;&gt;(cout,phone)
      cout &lt;&lt; phone&lt;&lt;endl;
      return 0;
  }
  </code></pre>
  
  <p>but compiling this shows me a compiler error: <code>undefined reference to 'operator&gt;&gt;(std:istream&amp;, Phonenumber&amp;)'</code>
  Could someone help me to resolve this error</p>