Hi guys..I am trying to make a program that can calculate the time difference in days from the current date..here is my code...it is bringing some bit of a problem...please help me out!Thanks
#include <iostream.h>
#include <cdate.h>
class Date
{
public:
int month;
int day;
int year;
static int dtab[2][13];
public:
int getMonth()
{
return month;
}
int getDay()
{
return day;
}
int getYear()
{
return year;
}
Date operator-(Date& d2);
Date& operator-()
{
month=-month;
day=-day;
year=-year;
return *this;
}
int compare(Date&);
int operator<(Date& d2)
{
return compare{d2) < 0;
}
int operator<=(const Date& d2)
{
return compare(d2) <= 0;
}
int operator>( Date& d2)
{
return compare(d2) > 0;
}
int operator>=( Date& d2)
{
return compare(d2) >= 0;
}
int operator==( Date& d2)
{
return compare(d2) == 0;
}
int operator!=( Date& d2)
{
return compare(d2) != 0;
}
static int isleap(int y)
{
return y%4 == 0 && y%100 != 0 || y%400 == 0;
}
};
int main()
{
Date today, d2;
cout << "Today's date is "<< today << endl;
cout << "Enter another date: ";
cin >> d2;
cout << "today -d2 = "<< today - d2 << endl;
cout << "d2 - today = "<< d2 - today << endl;
return 0;
}