Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C++ Consider the following Date class: #include <iostream> using namespace st

ID: 665315 • Letter: I

Question

In C++

Consider the following Date class:

#include <iostream>

using namespace std;

class MyDate

{

private:

int month, day, year;

public:

MyDate() {setDate(2,27,2006);}

MyDate(int, int, int);

void setDate(int mm, int dd, int yyyy);

void showDate();

};

MyDate::MyDate(int mm, int dd, int yyyy)

{

month = mm;

day = dd;

year = yyyy;

};

void MyDate::setDate(int mm, int dd, int yyyy)

{

month = mm;

day = dd;

year = yyyy;

};

void MyDate::showDate()

{

cout << "The date is " << month << "/" << day << "/" << year% << endl;

};

END HERE...

Write a test main that will create two date instances date1 inititalized to April, 17, 2012 and date2 that is set to today, then show both dates with each display on its own line.

Explanation / Answer

#include using namespace std; class Dates { private: int month,day,year; static char slash; public: Dates();//constructor void getDate(int m, int d, int y);//prototype for method getDate() void showDate();//prototype for method showDate() }; Dates::Dates() { Dates::day=1; Dates::month=1; Dates::year=2000; } //Dates::slash="/";//iniatialization of static slash variable char Dates::slash='/'; //function definitions for class Dates void Dates::getDate(int m, int d, int y) { Dates::day=d; Dates::month=m; Dates::year=y; } void Dates::showDate() { cout