title: istream operator overloading c++
body: <p>i'm trying to do a simple istream operator overloading, but for some reason, once entering this function, the program enters an infinite loop.
  please help!</p>
  
  <p>my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
   class date{
  
  int m_day,m_month,m_year;
  
  public:
  
  date(int day=1,int month=1,int year=2000){    //constructor
      if (day&gt;0 &amp;&amp; day&lt;32 &amp;&amp; month&gt;0 &amp;&amp; month&lt;13){
          m_day =day;
          m_month=month;
          m_year=year;
      }
  }
  
  
  friend ostream&amp; operator&lt;&lt; (ostream&amp; out, const date&amp; d);
  friend istream&amp; operator&gt;&gt; (istream&amp; in, const date&amp; d);
  };
  
  
  istream&amp; operator&gt;&gt; (istream&amp; stream, const date&amp; d){              //overload &gt;&gt;
  stream &gt;&gt; d.m_day;
  return stream;
  
  }
  
  void main(){  
  
  date date1;
  
  cin&gt;&gt;date1;                   //check istream
  
  getchar();
  }
  </code></pre>