title: Ambiguous constructor call
body: <p>I'm trying to create a simple date class, but I get an error on my main file that says, "call of overloaded Date() is ambiguous."  I'm not sure why since I thought as long as I had different parameters for my constructor, I was ok.  Here is my code:</p>
  
  <p>header file:</p>
  
  <pre><code>#ifndef DATE_H
  #define DATE_H
  using std::string;
  
  class Date
  {
  public:
      static const int monthsPerYear = 12; // num of months in a yr
      Date(int = 1, int = 1, int = 1900); // default constructor
      Date(); // uses system time to create object
      void print() const; // print date in month/day/year format
      ~Date(); // provided to confirm destruction order
      string getMonth(int month) const; // gets month in text format
  private:
      int month; // 1 - 12
      int day; // 1 - 31 
      int year; // any year
  
      int checkDay(int) const;
  };
  
  #endif
  </code></pre>
  
  <p>.cpp file</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;string&gt;
  #include &lt;ctime&gt;
  #include "Date.h"
  using namespace std;
  
  Date::Date()
  {
      time_t seconds = time(NULL);
      struct tm* t = localtime(&amp;seconds);
      month = t-&gt;tm_mon;
      day = t-&gt;tm_mday;
      year = t-&gt;tm_year;
  }
  
  Date::Date(int mn, int dy, int yr)
  {
      if (mn &gt; 0 &amp;&amp; mn &lt;= monthsPerYear)
          month = mn;
      else
      {
          month = 1; // invalid month set to 1
          cout &lt;&lt; "Invalid month (" &lt;&lt; mn &lt;&lt; ") set to 1.\n";
      }
  
      year = yr; // could validate yr
      day  = checkDay(dy); // validate the day
  
      // output Date object to show when its constructor is called
      cout &lt;&lt; "Date object constructor for date ";
      print();
      cout &lt;&lt; endl;
  }
  
  void Date::print() const
  {
      string str;
      cout &lt;&lt; month &lt;&lt; '/' &lt;&lt; day &lt;&lt; '/' &lt;&lt; year &lt;&lt; '\n';
  
      // new code for HW2
      cout &lt;&lt; setfill('0') &lt;&lt; setw(3) &lt;&lt; day;  // prints in ddd
      cout &lt;&lt; " " &lt;&lt; year &lt;&lt; '\n';             // yyyy format
  
      str = getMonth(month);
  
      // prints in month (full word), day, year
      cout &lt;&lt; str &lt;&lt; " " &lt;&lt; day &lt;&lt; ", " &lt;&lt; year &lt;&lt; '\n';
  }
  </code></pre>
  
  <p>and my main.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Date.h"
  using std::cout;
  
  int main()
  {
      Date date1(4, 30, 1980);
      date1.print();
      cout &lt;&lt; '\n';
  
      Date date2;
      date2.print();
  
  
  }
  </code></pre>