#include class Date { int mo, da, yr; public: Date(int m=0, int d=0, int y=0) { mo = m; da = d; yr = y; } void display() const { std::cout << mo << '/' << da << '/' << yr; } // Overloaded operators. bool operator==(Date& dt) const; bool operator<(Date&) const; }; // Overloaded equality operator definition. bool Date::operator==(Date& dt) const { return (this->mo == dt.mo && this->da == dt.da && this->yr == dt.yr); } // Overloaded less-than operator definition. bool Date::operator<(Date& dt) const { if (this->yr == dt.yr) { if (this->mo == dt.mo) return this->da < dt.da; return this->mo < dt.mo; } return this->yr < dt.yr; } int main() { Date date1(12,7,1941), date2(2,22,1990), date3(12,7,1941); if (date1 < date2) { date1.display(); std::cout << " is less than "; date2.display(); } std::cout << '\n'; if (date1 == date3) { date1.display(); std::cout << " is equal to "; date3.display(); } return 0; }