1) how can i validate the months , days and year together with the subclass earlier, if the year same...nothing provided.,. no result.pls show example...
2)i really have no idea on counting the next christmas day by providing a specified date on my christmas subclass.pls show me some examples..
3)how to count the different between the two dates....by using the below class... any clues...will be appreciate
#include<iostream.h>
#include<string.h>
#include<stdio.h>
class Date
{ //data
public:
Date(int =1,int=1,int=1900);//default constructor
~Date();
protected:
int month;
int day;
int year;
int checkDay(int);
//data
};
///////////////////////////////////////////////////////////////////////////
// Date constructor with range checking
Date:ate(int m, int d, int y)
{
month= (m > 0 && m<=12)? m:1;
day= checkDay(d);
year=(y>=1900 && y <2100)? y:1900;
}
//utility function to confirm proper day value
//based on month and year
int Date::checkDay(int testDay)
{
static int daysPerMonth[13]={0,31,28,31,30,
31,30,31,31,30,
31,30,31};
if(month !=2)
{
if(testDay > 0 && testDay <= daysPerMonth[month])
return testDay;
}
else //February: Check for possible leap year
{
int days= (year % 400 == 0 ||
(year % 4 == 0 && year % 100 != 0) ? 29:28);
if(testDay > 0 && testDay <= days)
return testDay;
}
return 1;
}
Date::~Date()
{
}