Create a "Date" class that contains:

In main (in the following order):

  1. instantiate one date object (date1) using the default constructor
  2. use the getters to display the month, day, and year of date1 (should print the default values)
  3. read keyboard input from the user for a month, day and year
  4. use the setters to set the values of date1 to the values that came from the user
  5. read keyboard input from the user for a second date
  6. use the constructor with three arguments to instantiate date2 to the second date input from the user
  7. print both objects using printDate
  8. print a message to say if the two months are the same (testing the sameMonth function)

Your code should be in three files:

Sample Output

Testing the default constructor and the getters
The initialized date is (M-D-Y):1-1-1

Please enter a date:(Month Day Year): 11 03 1976
Please enter a second date:(Month Day Year): 03 03 1999

Printing the two days: 
The date is (M-D-Y): 11-3-1976
The date is (M-D-Y): 3-3-1999
The months are different 

If you are having trouble compiling your class, check for these common errors:

  1. You have forgotten the semi-colon(;) after the closing curly bracket (}) for the class definition (in the Date.h file)
  2. You have forgotten the scope resolution as in: void Date::setYear(int y) (in the Date.cpp file)
  3. You forgot the () after the function name. For example, you should write: cout << date1.getYear() (in main.cpp)

For the StudentClass that we go over this week, see StudentClass.cpp