Question: Consider the class dateType given in Chapter 1 1 . In this class, add the functions to overload the increment and decrement operators to increase
Consider the class dateType given in Chapter In this class, add the functions to overload the increment and decrement operators to increase the date by a day and decrease the date by a day, respectively; relational operators to compare two dates; and stream operators for easy input and output. Assume that the date is input and output in the form MMDD YYYY Also write a program to test your class.
There are three files in this: main.cpp dataType.h and dataType.cpp
main.cpp
#include
using namespace std;
int main
Write your main here
return ;
dataType.h
#ifndef dateTypeH
#define dateTypeH
#include
using namespace std;
class dateType
friend ostream& operatorostream& const dateType&;
friend istream& operatoristream& dateType&;
public:
void setDateint int, int;
void setMonthint;
void setDayint;
void setYearint;
int getMonth const;
int getDay const;
int getYear const;
Declare overloaded operator functions
bool isLeapYear;
int getDaysInMonth;
dateTypeint int int ;
private:
int dMonth;
int dDay;
int dYear;
;
#endif
dataType.cpp
#include
#include "dateType.h
using namespace std;
void dateType::setDateint month, int day, int year
if year
dYear year;
else
dYear ;
if month && month
dMonth month;
else
dMonth ;
switch dMonth
case :
case :
case :
case :
case :
case :
case :
if day && day
dDay day;
else
dDay ;
break;
case :
case :
case :
case :
if day && day
dDay day;
else
dDay ;
break;
case :
if isLeapYear
if day && day
dDay day;
else
dDay ;
else
if day && day
dDay day;
else
dDay ;
void dateType::setMonthint m
dMonth m;
void dateType::setDayint d
dDay d;
void dateType::setYearint y
dYear y;
int dateType::getMonth const
return dMonth;
int dateType::getDay const
return dDay;
int dateType::getYear const
return dYear;
int dateType::getDaysInMonth
int noOfDays;
switch dMonth
case :
case :
case :
case :
case :
case :
case :
noOfDays ;
break;
case :
case :
case :
case :
noOfDays ;
break;
case :
if isLeapYear
noOfDays ;
else
noOfDays ;
return noOfDays;
bool dateType::isLeapYear
if dYear && dYear dYear
return true;
else
return false;
dateType::dateTypeint month, int day, int year
setDatemonth day, year;
Overload Operators
My problem is to add and define the overloaded operators
and to write a main.cpp all in C
Please try to work this with three files instead of one
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
