Incrementing time and calendarfrom 1999-2000
I want to increment time from dec 31,1999 23:59:59 to Jan 1,2000 00:00:01.We have to use validation for the year month and day and time min sec..etc.
Any suggestions on how to go on from here using classes and such? Any help would be greatly appreciated.Thanks!Here is an example of my code:
#include<iostream.h>
#include<iomanip.h>
class date
{
int day;
int month;
int year;
public:
date( int d= 31, int m= 12, int y= 1999)
{
status = true;
setDate(d, m, y);
print();
}
void setDate(int d, int m, int y)
{
int arr[13]= {0.31,28,31,30,31,30,31,31,30,31,30,31};
year = y;
if (m <= 12 && m > 0)
{
month = m;
if (d > 0 && d <= arr[m])
{
day = d;
}
else
{
day =0;year = 0; month= 0;status= false;
}
}
else
{
day =0;year = 0; month= 0;status= false;
}
}
bool status;
void print()
{
cout<< setw(10)
<< status
<< setw(10)
<< day
<< setw(10)
<< month
<< setw(10)
<< year
<<endl;
}
};
class time: public date
{
int hours;
int mins;
int secs;
public:
time(){int hours=0,int mins=0,int secs=0;}
//this is the trouble spot!!!!
void main()
{
date d(11,2,1999);
d.setDate(1,1,2000);
d.print();
/* time t;
t.tick(1);
*/
}
I am just not sure of where to go in the time dept.Any little push would help alot!