Here's what you're being asked to implement. This is just a shell, so you have to fill in all the details yourself. That includes adding comments! Good luck.
#include <iostream>
using namespace std;
class Date
{
public:
Date();
Date(int day, int month, int year);
bool operator==(const Date& that) const;
bool operator!=(const Date& that) const;
bool operator<(const Date& that) const;
bool operator>(const Date& that) const;
private:
int day_;
int month_;
int year_;
static const int DaysPerMonth[12];
};
const int Date::DaysPerMonth[12] =
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
Date::Date() : year_(1900), month_(1), day_(1) { }
Date::Date(int day, int month, int year) :
day_(day),
month_(month),
year_(year)
{
}
bool Date::operator==(const Date& that) const
{
return false;
}
bool Date::operator!=(const Date& that) const
{
return false;
}
bool Date::operator<(const Date& that) const
{
return false;
}
bool Date::operator>(const Date& that) const
{
return false;
}
ostream& operator<<(ostream& stream, const Date& date)
{
return stream;
}
istream& operator>>(istream& stream, Date& date)
{
return stream;
}
int main()
{
Date d1, d2(1,2,2017);
cin >> d1;
if(d1 < d2)
cout << d1 << " is before " << d2;
else if(d1 > d2)
cout << d2 << " is before " << d1;
else
cout << "The dates are equal.";
cout << endl;
return 0;
}