Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer the following in C++ please, thank you. Define a class named Date with three private data members named month (integer), day (integer), and
Please answer the following in C++ please, thank you.
Define a class named Date with three private data members named month (integer), day (integer), and year (integer) as follows: - This class has a private member function void checkDate( ) that validates a date as follows: - The month must be an integer value from 1 to 12 . - The day must be an integer value from 1 to 31 . - The year must be an integer value from 1960 to 2011. - Function checkDate( ) calls the library function exit( ) to terminate the program if any of the above conditions is not satisfied. - This class default constructor sets the month data member to 1, the day data member to 1, and the year data member to 1960: The default date is 1/1/1960. - The class constructor with parameters calls function checkDate( ) to check the date after it has set the values for the data members month, day, and year. - The class also has the following public member functions: - void inputDate( ) that reads the values for the data members month, day and year, and then calls function checkDate( ) to check the date. - void outputDate( ) that prints the date in the format: month/day/year. - int getMonth( ), int getDay( ), and int getYear( ). These functions return the value of the month data member, the value of the day data member, and the value of the year data member respectively. - Place the definition of the class in the header file Date.h, and the definitions of the functions in the source file Date.cpp. - Note: the header files iostream, iomanip, cstdlib, and Date.h must be included in the source file Date.cppStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started