C++ Time class has no compilation error, execution stops and app crashes error in checkDay function
<p>below is the date.h , date. cpp and main.cpp
i do not get any compilation error. but the run of exe stops , this does not happen when checkday function of date class is removed. what is wrong with the function? i am using dev C++ </p>

<pre><code>#ifndef DATE_H
#define DATE_H

class Date{
  private: 
           int day, month, year;
  public:
           Date(int = 1, int = 1, int = 1990);
           ~Date();
           void setDay(int);
           int checkDay(int); //return int i.e. default day 1 or correct date inputted :)
           void setMonth(int);
           void setYear(int);
           int getDay() const;
           int getMonth() const;
           int getYear() const;
           void printDate() const;
};

#endif

#include &lt;iostream&gt;
#include &lt;cmath&gt;
using namespace std;
#include "date.h"

Date::Date(int d, int m, int y){

           //setDay(d); calling setDay() here caused crash
           setMonth(m);
           setYear(y);
           setDay(d);
}
 Date::~Date(){

          cout&lt;&lt;"Date destructor called...\n";
}
void Date::setDay(int d){

          day = checkDay ( d ) ;
}
int Date::checkDay(int dd){ /*COMMENTING THIS FUNCTION REMOVES RUN TIME   ERROR */

          static int daysInmonth[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
          if ( dd &gt; 0 &amp;&amp; dd &lt;= daysInmonth[month] )
             return dd;
          if( ( year%400==0||( year%100!=0 &amp;&amp; year%4==0))&amp;&amp; month==2 &amp;&amp; dd==29) 
             return dd;               
          return 1;        
}

void Date::setMonth(int m){

          month = ((m &gt; 0 &amp;&amp; m &lt;=12) ? m : 1 );
}
void Date::setYear(int y){

          if (((int)log10((double)y) + 1)!=4) //ild1 != 4
             year = 1990;
          else year = y;
}
int Date::getDay() const{

          return day;
}
int Date::getMonth() const{

          return month;
}
int Date::getYear() const{

          return year;
} 

void Date::printDate() const{

          cout&lt;&lt;"Date: "&lt;&lt;getDay()&lt;&lt;"/"&lt;&lt;getMonth()&lt;&lt;"/"&lt;&lt;getYear()&lt;&lt;endl;
}



#include &lt;cstdlib&gt;    
#include &lt;iostream&gt;
#include "date.h"
using namespace std;

int main()
{

    Date date1( 2, 3, 2004),date2,date3( 2, 1, -1980), 
      date4(0, 12, 2990),date5(29, 2, 2001), date6(12,12, 98686);

cout&lt;&lt;"User inputted valid date: "; date1.printDate();
cout&lt;&lt;"\nDefault valid date: "; date2.printDate();
cout&lt;&lt;"\nAttempt to input invalid date: 2/1/-1980 "; date3.printDate();
cout&lt;&lt;"\nAttempt to input invalid date: 0/12/2990 "; date4.printDate();
cout&lt;&lt;"\nAttempt to input invalid date: 29/2/2001 ( non leap year) "; date5.printDate();   
cout&lt;&lt;"\nAttempt to input invalid date: 12/12/98686 "; date6.printDate();  

cout&lt;&lt;endl;
system("PAUSE");
return EXIT_SUCCESS;
}
</code></pre>
