Question: Design a class called Date. The class should store a date in three integers: month, day, and year. There should be member functions to print
Design a class called Date. The class should store a date in three integers: month, day, and year. There should be member functions to print the date in the following formats: 12/25/10, December 25, 2010, 25 December 2010. Input Validation: Do not accept values for the day greater than 31 or less than 1. Do not accept values for the month greater than 12 or less than 1. Requirement Modify the Date class. The new version should have the following overloaded operators: ? ++ Prefix and postfix increment operators. These operators should increment the objects day member. ? -- Prefix and postfix decrement operators. These operators should decrement the objects day member. ? - Subtraction operator. If one Date object is subtracted from another, the operator should give the number of days between the two dates. For example, if April 10, 2010 is subtracted from April 18, 2010, the result will be 8. Requirement The class should detect the following conditions and handle them accordingly:
? When a date is set to the last day of the month and incremented, it should become the first day of the following month.
? When a date is set to December 31 and incremented, it should become January 1 of the following year.
? When a day is set to the first day of the month and decremented, it should become the last day of the previous month.
? When a date is set to January 1 and decremented, it should become December 31 of the previous year. Demonstrate the classs capabilities in a program using C++.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
