Consider the class dateType given in Chapter 13. In this class, add the function
ID: 3653821 • Letter: C
Question
Consider the class dateType given in Chapter 13. In this class, add the functions to overload the increment and decrement operators to increase the date by a day and decrease the data 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 MM-DD-YYYY.) Also write a program to test your class.
Add this work to the program given and write the main program.
i have the dateType.h and dateTypeImp.cpp.
dateType.h
#ifndef dateType_H
#define dateType_H
class dateType
{
public:
void setDate(int month, int day, int year);
//Function to set the date.
//The member variables dMonth, dDay, and dYear are set
//according to the parameters.
//Postcondition: dMonth = month; dDay = day;
// dYear = year
int getDay() const;
//Function to return the day.
//Postcondition: The value of dDay is returned.
int getMonth() const;
//Function to return the month.
//Postcondition: The value of dMonth is returned.
int getYear() const;
//Function to return the year.
//Postcondition: The value of dYear is returned.
void printDate() const;
//Function to output the date in the form mm-dd-yyyy.
dateType(int month = 1, int day = 1, int year = 1900);
//Constructor to set the date
//The member variables dMonth, dDay, and dYear are set
//according to the parameters.
//Postcondition: dMonth = month; dDay = day; dYear = year;
// If no values are specified, the default
// values are used to initialize the member
// variables.
private:
int dMonth; //variable to store the month
int dDay; //variable to store the day
int dYear; //variable to store the year
};
#endif
dateTypeImp.cpp
//Implementation file date
#include <iostream>
#include "dateType.h"
using namespace std;
void dateType::setDate(int month, int day, int year)
{
dMonth = month;
dDay = day;
dYear = year;
}
int dateType::getDay() const
{
return dDay;
}
int dateType::getMonth() const
{
return dMonth;
}
int dateType::getYear() const
{
return dYear;
}
void dateType::printDate() const
{
cout << dMonth << "-" << dDay << "-" << dYear;
}
//Constructor with parameters
dateType::dateType(int month, int day, int year)
{
dMonth = month;
dDay = day;
dYear = year;
}
Please and thank you
Explanation / Answer
Here you go. Correct postfix operators overloaded. Please rate so I can unhost. Comment if any question https://www.dropbox.com/s/s5sn9mifacgh1d1/dateType(overload postfix).cpp.txt