Design a class called Date that has integer data members to store month, day, and year. The class should have a three-parameter (day-of-month, month, year) default constructor that allows the date to be set at the time a new Date object is created.

Design a class called Date that has integer data members to store month, day, and year.  The class should have a three-parameter (day-of-month, month, year) default constructor that allows the date to be set at the time a new Date object is created.

LANGUAGE: C++

CHALLENGE:

Design a class called Date that has integer data members to store month, day, and year.
The class should have a three-parameter (day-of-month, month, year) default constructor that allows the date to be set at the time a new Date object is created.
If the user creates a Date object without passing any arguments, or if any of the values passed are invalid, the default values of 1, 1, 2001 (i.e., January 1, 2001) should be used (see below for the definition of invalid values).

The class should have member functions to print the date in the following formats:
3/15/13 (printNumerical)
March 15, 2013 (printMonthFirst)
15 March 2013 (printDateFirst)

For the purposes of this exercise, the following are invalid values:
For day of month: any value less than 1 or greater than 31 (so February 30 or April 31 would be acceptable)
For month: any value less than 1 or greater than 12
For year: any value less than 0

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days – Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level