Modify the Date class inProgramming Challenge 1 of Chapter 13. The newversion sh
ID: 3613819 • Letter: M
Question
Modify the Date class inProgramming Challenge 1 of Chapter 13. The newversion
should have the following overloadedoperators:
++ Prefix and postfix incrementoperators. These operatorsshould increment the object’s day member.
-- Prefix and postfix decrementoperators. These operatorsshould decrement the object’s day member.
- Subtraction operator.If one Date object issubtracted from another, the operator should give the number ofdays between the two dates. For example, if April 10, 2009 issubtracted from April 18, 2009, the result will be8.
<<cout’sstream insertion operator. Thisoperator should cause the date to be displayed in theform April 18, 2009
>>cin’sstream extraction operator. Thisoperator should prompt the user for a date to be stored ina Date object.
• When a date is setto the last day of the month and incremented, it should become thefirst day of the following month.
• When a date is setto December 31 and incremented, it should become January 1 of thefollowing year.
• When a day is setto the first day of the month and decremented, it should become thelast day of the previous month.
• When a date is setto January 1 and decremented, it should become December 31 of theprevious year.
Demonstrate the class’s capabilities in asimple program.
Explanation / Answer
please rate - thanks with ++ and -- #include #include using namespace std; int validdate(int,int); class Date { private: int month,day,year; int days[12]; public: Date(int m, int d, int y) { month=m; day=d; year=y; setdaysinmonth(); } void Date::setdaysinmonth() { days[0] = 31; days[1] = 28; days[2] = 31; days[3] = 30; days[4] = 31; days[5] = 30; days[6] = 31; days[7] = 31; days[8] = 30; days[9] = 31; days[10] = 30; days[11] = 31; } void Date::printslash() {int yearminus2000; yearminus2000=year-2000; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.