Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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, separate 3 files : dateType.h , dateType.cpp, main.cpp dateType.h #pragma once 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; } dateType.cpp #include #include #include "dateType.h" using namespace std; //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

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions