Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and implement a C++ class called Date that has the following private member variables month (int) day (nt) . year (int Add the following

image text in transcribed
Design and implement a C++ class called Date that has the following private member variables month (int) day (nt) . year (int Add the following public member functions to the class. Default Constructor with all default parameters: The constructors should use the values of the month, day, and year arguments passed by the client program to set the month, day, and year member variables. The constructor should check if the values of the parameters are valid (that is day is between 1-31, month is between 1-12 and year is >0). If not, the constructor should use default values 1, 1, 2000 for month, day, and year respectively. . Accessors (getters): write one for each member variable month, day, and year. Mutators (setters): write one for each member variable month, day, and year. The mutators should check if the values passed are valid (that is day is between 1-31, month is between 1-12 and year is >0) and if not, do not update the member variable with an invalid value. . print1: this function should print the date in "month/day/year" format to the screen, where each month, day and year are int's. For example, "1/2/2012" print2: this function should print the date in "month day, year" format to the screen where day and year are int's and month is a string. For example, "January 2, 2012 b) to create at least two different Date objects and call both print1 and print2 functions, etc. Demonstrate the use of Date class by writing code in your main function. Make sure

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions