Question: a ) The default constructor should initialise the date to 1 4 September 1 7 5 2 . b ) The overloaded constructor should initialise

a) The default constructor should initialise the date to 14 September 1752.
b) The overloaded constructor should initialise the date with the given day, month and year.
c) The functions getDay(), getMonth() and getYear() should return the current
day, month and year respectively.
d) The functions setDay(), setMonth() and setYear() should change the current
day, month or year to the given value.
e) The operator ++ should advance the date by one, and return the new date.
f) The operator -- should set the date back by one day, and return the new date.
g) The operator < should calculate whether the receiving date object (left
argument) precedes the parameter date (right argument).
For example, Date(1,1,2002)< Date(1,3,2002).
h) The private member function monthLength() should return the length of the current
month, taking into account leap years. A year is a leap year if it is either (i) divisible by
4, but not by 100, or (ii) divisible by 400. In a leap year, February has 29 days,
otherwise it has 28 days.
i) Also overload the insertion operator << to output a date to the screen. For example,
the date in (a) above should be written as: 14 September 1752.
Test the Date class in a C++ program that will do the following:
Declare a new Date object called d1.
Display the day, month and year of d1 on the screen.
Change the date to 28 February 2000.
Advance this date by one and display the new date on the screen.
Now change the date to 1 January 2002.
Set this date back by one and display the new date on the screen.
Finally change the date to 31 December 2002.
Advance this date by one and display the new date on the screen.
Declare a second date object d2(1,1,2003).
Determine if d1 is earlier than d2 and write the result on the screen.
Operators ++,-- and < are declared as member functions in the class
declaration above. Implement these operators as friend functions of class
Date also. Run your program twice (each time with a different version of
the overloaded operator ++,-- and <; comment the other versions out during
each run).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!