title: Debug error, abort() has been called in c++
body: <p>I'm trying to perform error checking on my initializer value for date, so that a day or month outside the acceptable range will stop the program from debbuging, but I'm getting a debug error even for the acceptable range. I don't know where the error is from, so i posted the code.</p>
  
  <pre><code>// ConsoleApplication56.cpp : Defines the entry point for the console application.
  //
  
  #include "stdafx.h"
  #include&lt;iostream&gt;
  #include&lt;stdexcept&gt;
  #include&lt;array&gt;
  
  using namespace std;
  
  class Date
  {
  public:
      explicit Date(int mo, int da, int ye)
      {
          setDate( mo, da, ye);
      }
      void setDate(int &amp;m, int &amp;d, int &amp;y)
      {
  
              setMonth(m);
              setDay(d);
              setYear(y);
  
      }
      void setMonth(int &amp;m)
      {
          if (month&gt;0 &amp;&amp; month &lt;13)
          {
          month = m;
          }else
              throw invalid_argument("month must be 1-12");
      }
      unsigned int getMonth()const
      {
          return month;
      }
      void setDay(int &amp;d)
      {
          if(day&gt;0 &amp;&amp; day&lt;32)
          {
          day = d;
          }else
              throw invalid_argument("day must be 0-31");
      }
      unsigned int getDay()const
      {
          return day;
      }
      void setYear(int &amp;y)
      {
          year = y;
  
      }
      unsigned int getYear()const
      {
          return year;
      }
      void print()
      {
          cout&lt;&lt; month &lt;&lt;'/' &lt;&lt; day &lt;&lt; '/' &lt;&lt; year;
      }
      void nextDay()
      {
          int numberOfDaysToAdd = 1;
      array &lt;int,12&gt; daysInAMonth = {31,28,31,30,31,30,31,31,30,31,30,31};
  
      cout &lt;&lt; "the date before is: " &lt;&lt; month &lt;&lt; "/" &lt;&lt; day &lt;&lt; "/" &lt;&lt; year &lt;&lt; endl;
  
      day += numberOfDaysToAdd;
  
      while (day &gt; daysInAMonth [month - 1 ] )
      {
          day-= daysInAMonth [month - 1 ];
          month++;
  
          if (month &gt; 12){
            month = 1;
            year++;
          }
  
      }
  
      cout &lt;&lt; "the day after is: " &lt;&lt;  month &lt;&lt; "/" &lt;&lt; day &lt;&lt; "/" &lt;&lt; year &lt;&lt; endl;
  
      }
  
  private:
      unsigned int month;
      unsigned int day;
      unsigned int year;
  };
  
  
  int main()
  {
      char response = 'y';
      Date date(12, 3, 2013 );
  
      cout&lt;&lt;"The date is :";
      date.print();
      cout&lt;&lt;endl;
      cout&lt;&lt;endl;
  
      cout&lt;&lt;"do you wish to check the next date(y/n)? :";
      cin &gt;&gt; response;
      cout&lt;&lt;endl;
  
      while(response == 'y')
      {
      date.nextDay();
      cout&lt;&lt;endl;
      cout&lt;&lt;"do you wish to check the next date(y/n)? : ";
      cin &gt;&gt; response;
      cout&lt;&lt;endl;
      }
      return 0;
  </code></pre>
  
  <p>}</p>