Write in C++: Consider the class dateType given in chapter 13. In this class, ad
ID: 3935811 • Letter: W
Question
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;
}
Explanation / Answer
#include using namespace std; // Variable declaration: extern int a, b; extern int c; extern float f; int main () { // Variable definition: int a, b; int c; float f; // actual initialization a = 10; b = 20; c = a + b; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.