Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data data::operator+=(const data &d)
- {
- return data(this->day + d.day, this->month + d.month, this->year + d.year);
- }
- data data::operator+=(const int &d)
- {
- data temp(day,month,year);
- temp.day = temp.day + d;
- for(int i = 0;i<=20;i++)
- {
- if(temp.month == 1 || temp.month == 3 || temp.month == 5 || temp.month == 7 || temp.month == 8 || temp.month == 10 || temp.month == 12)
- {
- if (temp.day>31)
- {
- temp.month++;
- temp.day = temp.day - 31;
- }
- }
- if(temp.month == 4 || temp.month == 6 || temp.month == 9 || temp.month == 11 )
- {
- if (temp.day>30)
- {
- temp.month++;
- temp.day = temp.day - 30;
- }
- }
- else if(temp.day>28)
- {
- temp.month++;
- temp.day = temp.day - 28;
- }
- if(temp.month>12)
- {
- temp.year++;
- temp.month = temp.month - 12;
- }
- }
- return temp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement