title: Undefined Reference when trying to Verify Date
body: <p>This is my error</p>
  
  <p>/tmp/cce7wiXI.o: In function <code>main':
  ChronoTest.cpp:(.text+0x652): undefined reference to</code>Chrono::operator>>(std::istream&amp;, Chrono::Date&amp;)'
  collect2: error: ld returned 1 exit status</p>
  
  <p>This is my header file</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  namespace Chrono{
      enum class Month{
  
      jan=1,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec
      };
      class Date{
          public:
  
          class Invalid{};
  
          Date(int y, Month m, int d);
          Date();
  
          int day() const{return d;}
          Month month()const{return m;}
          int year()const{return y;}
  
  
      void add_day(int n);
      void add_month(int n);
      void add_year(int n);
  
      private:
          int y;
          Month m;
          int d;
      };
      bool is_date(int y, Month m, int d);
      bool leapyear(int y);
  
      bool operator==(const Date&amp; a, const Date&amp; b);
      bool operator!=(const Date&amp; a, const Date&amp; b);
  
      ostream&amp; operator&lt;&lt;(ostream&amp; os, const Date&amp; d);
      istream&amp; operator&gt;&gt;(istream&amp; is, Date&amp; dd);
  
      Date&amp; operator++(Date&amp; d);
      Date operator++(Date&amp; dl, int);
  }
  </code></pre>
  
  <p>And this is my main file</p>
  
  <pre><code>#include "Chrono.h"
  
  
  //------------------------------------------------------------------------------
  
  namespace Chrono{
  
      Date::Date(int yy, Month mm, int dd)
      :y{yy},m{mm},d{dd}
          {
              if(!is_date(yy,mm,dd))throw Invalid();
          }
  
          const Date&amp; default_date()
          {
              static Date dd{2001,Month::jan,1};
              return dd;
              }
              Date::Date()
              :y{default_date().year()},
              m{default_date().month()},
              d{default_date().day()}{}
  void Date::add_day(int n){
      for(int i = 0; i&lt;n; ++i){
      ++d;
      if(!is_date(y, m, d)){
          d = 1;
          if(m == Month::dec){
              m = Month::jan;
              ++y;
          }else
              m = Month(static_cast&lt;int&gt;(m)+1);
      }
      }
  }
  void Date::add_month(int n){
  
  }
  void Date::add_year(int n){
      if (m==Month::feb&amp;&amp; d==29&amp;&amp;!leapyear(y+n)){
          m = Month::mar;
          d=1;
      }
      y+=n;
  }
  
  bool is_date(int y, Month m, int d)
  {
      if(d&lt;=0)return false;
      if(m&lt;Month::jan || Month::dec&lt;m)return false;
  
      int days_in_month = 31;
  
      switch(m){
          case Month::feb:
              days_in_month = (leapyear(y))?29:28;
              break;
          case Month::apr:case Month::jun:case Month::sep:case Month::nov:
               days_in_month = 30;
              break;
      }
      if(days_in_month&lt;d)return false;
      return true;
  }
  bool leapyear(int y)
  {
      return false;
  }
  bool operator==(const Date&amp; a, const Date&amp; b)
  {
      return a.year()==b.year()
      &amp;&amp;a.month()==b.month()
      &amp;&amp;a.day()==b.day();
  }
  bool operator!=(const Date&amp; a, const Date&amp; b)
  {
      return !(a==b);
  }
  ostream&amp; operator&lt;&lt;(ostream&amp; os, const Date&amp; d)
  {
      return os&lt;&lt;'('&lt;&lt;d.year()
               &lt;&lt;','&lt;&lt;static_cast&lt;int&gt;(d.month())
               &lt;&lt;','&lt;&lt;d.day()&lt;&lt;')';
  }
  istream&amp; operator&lt;&lt;(istream&amp; is, Date&amp; dd)
  {
      int y, m, d;
      char ch1, ch2, ch3, ch4;
      is&gt;&gt;ch1&gt;&gt;y&gt;&gt;ch2&gt;&gt;m&gt;&gt;ch3&gt;&gt;d&gt;&gt;ch4;
      if(!is)return is;
      if(ch1!='('||ch2!=','||ch3!=','||ch4!=')'){
          is.clear(ios_base::failbit);
          return is;
      }
      dd = Date(y, Month(m), d);
      return is;
  }
  Date operator++(Date&amp; d1, int)
  {
      Date d2 = d1;
      d1.add_day(1);
      return d2;
  }
  enum class Day{
      sunday,monday,tuesday,wednesday,thursday,friday,saturday
  };
  
  Day day_of_week(const Date&amp; d)
  {
  
  }
  Date next_Sunday(const Date&amp; d)
  {
      return d;
  }
  Date next_weekday(const Date&amp; d)
  {
      return d;
  }
  }
  int main()
  try
  {
  
      using namespace Chrono;
      cout &lt;&lt; "enter some dates: ";
      Date d;
      cin&gt;&gt; d;
      cout&lt;&lt; d &lt;&lt; "is a valid date!";
  
      // For some Windows(tm) setups
  }
  catch (Chrono::Date::Invalid&amp;) {
      cerr &lt;&lt; "error: Invalid date\n"; 
      // For some Windows(tm) setup
      return 1;
  }
  catch (runtime_error&amp; e) {  // this code is to produce error messages
      cout &lt;&lt; e.what() &lt;&lt; '\n';
      // For some Windows(tm) setups
  }
  </code></pre>
  
  <p>I'm trying to input a date to validate if it is a real day or not. </p>