Write in C Consider the class dateType given in chapter 13 I
Write in C++:
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 date by a day, respectively; relational operators to compare two dates; and stream operators for easy input and output. (Assume the date is input and output in the form MM-DD-YYYY.) Also write a program to test your code.
Im using Microsoft Visual Studios 2015 C++, if the answer could be given using the same software that would be awesome!!
I have the header.h and the dateTypeImp.cpp but I need a main file to test the other two with.
dateType.h file
#ifndef dateType_H
#define dateType_H
class dateType
{
public:
void setDate(int month, int day, int year);
int getDay() const;
int getMonth() const;
int getYear() const;
void printDate() const;
dateType(int month = 1, int day = 1, int year = 1900);
private:
int dMonth;
int dDay;
int dYear;
};
#endif
dateTypeImp.cpp file
#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;
}
dateType::dateType(int month, int day, int year)
{
dMonth = month;
dDay = day;
dYear = year;
}
Solution
#include
