Question: Create a C++ console application that defines a Date class. The class should declare 3 integer data members for the year, month, and day. Define
Create a C++ console application that defines a Date class. The class should declare 3 integer data members for the year, month, and day. Define a 3-arg constructor which performs validation of the month and day and then initializes the data members. The month value should be between 1 and 12, and the day value should be validated for the given month. February can be assumed to have 28 days. If validation fails then an error message should be printed to the screen and the application should exit using the exit) function. Define 3 accessor functions for the private data members. Define a member function named compareDates which should accept a Date object as a constant reference parameter. The method should compare the data members of each object and then print out the dates in chronological order. Define a private member function named print Date which will handle the printing of dates in a consistent format. This method should be very short. From main, prompt the user for input and then create 2 Date objects. Call the compareDates method on one ot passing the other object as the argument to the method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
