Question: The class dateType is designed to implement the date in a program, but the member function setDate and the constructor do not check whether the

The class dateType is designed to implement the date in a program, but the member function setDate and the constructor do not check whether the date is valid before storing the date in the data members. Rewrite the definitions of the function setDate and the constructor so that the values for the month, day, and the year are checked before storing the date into the data members. Add a function member, isLeapYear, to check whether a year is a leap year. Moreover, write a test program to test your class.

*Note: I need help to write out this problem in C++ while using Visual Studio 2017

//code

#include #include

class dateType { public: //custom methods void printDate() const;

//mutators void setDate(int month, int day, int year);

//accessors int getDay() const; int getMonth() const; int getYear() const;

//constructors dateType(int month = 1, int day = 1, int year = 1900);

//destructor ~dateType(); private: int dMonth; int dDay; int dYear; };

int main() {

}

//custom methods void dateType::printDate() const { cout << setfill('0'); cout << setw(2) << dMonth << '-' << setw(2) << dDay << '-' << dYear;

}

dateType::dateType(int month, int day, int year) { dMonth = month; dDay = day; dYear = year; }

dateType::~dateType() { dMonth = 1; dDay = 1; dYear = 1900; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!