#include<iostream.h>
#include<conio.h>
class update
{
int day,month,year;
public:
void read()
{
cin>>day>>month>>year;
}
void write()
{
cout<<day<<"\t"<<month<<"\t"<<year;
}
void operator ++();
};
void update::operator ++()
{
day++;
if(day>31)
{
if(month==12)
{
day=1;month=1;year++;
}
else
{
day=1;
month++;
}
}
if((month==4||month==6||month==9||month==11)&&(day>30))
{
day=1;
month++;
}
if(month==2)
{
if(year%4==0&&day>29)
{
day=1;
month++;
}
else
if(year%4!=0&&day>28)
{
day=1;
month++;
}
}
}
void main()
{
udate d1;
clrscr();
cout<<"Enter the date :";
d1.read();
cout<<"\n The given date is :";
d1.write();
++d1;
cout<<endl<<"\n The incremented date is : ";
d1.write();
getch();
}
#include<conio.h>
class update
{
int day,month,year;
public:
void read()
{
cin>>day>>month>>year;
}
void write()
{
cout<<day<<"\t"<<month<<"\t"<<year;
}
void operator ++();
};
void update::operator ++()
{
day++;
if(day>31)
{
if(month==12)
{
day=1;month=1;year++;
}
else
{
day=1;
month++;
}
}
if((month==4||month==6||month==9||month==11)&&(day>30))
{
day=1;
month++;
}
if(month==2)
{
if(year%4==0&&day>29)
{
day=1;
month++;
}
else
if(year%4!=0&&day>28)
{
day=1;
month++;
}
}
}
void main()
{
udate d1;
clrscr();
cout<<"Enter the date :";
d1.read();
cout<<"\n The given date is :";
d1.write();
++d1;
cout<<endl<<"\n The incremented date is : ";
d1.write();
getch();
}
No comments:
Post a Comment