C++ Date Class Implementation
Using C++ write a Date class with the necessary constructors and overloaded operator functions that makes use of the requisite main() function to produce the indicated output below.
The Required main() function
Date today; // initializes Date with current date
// Increment and decrement operators
cout << feb2815 << endl;
cout << feb2800 << endl;
cout << NewYearsDay << endl;
// Test plus operators
// Test minus operators
// Test the ! operator
// Test logic operators
- The program must use the main() listed above.
- The Date class must contain:
– 3 data members for month, day, and year.
– 3 constructors. The default constuctor should initialize using the current date.
– a static array member to hold the number of days in each month.
– a static const array string member to hold month names.
– necessary overloaded operator functions
– two friend functions:
. an overloaded insertion operator to print a Date using a mm/dd/yyyy format.
. a overloaded binary + operator to added a number of days to a Date (e.g. 60 + today).
Output produced 11/12/16
30 days from now: 12/12/2016
Days until the final = 30
02/28/2000 < 01/01/2016 ? true
– Store the year as a 4-digit integer number
– Use the time() and localtime() functions to get the current date.
– Write a function to test for leap year.
– Write and test one function at a time. Perform thorough testing, not just the the required main().
- File Format: C++ .cpp
- Version: c++11