#include // class declaration class Date { friend ostream& operator<<(ostream&, const Date&); // overload inserter operator friend istream& operator>>(istream&, Date&); // overload extractor operator private: int month; int day; int year; public: Date(int = 7, int = 4, int = 2001); // constructor }; // implementation section // overloaded insertion operator function ostream& operator<<(ostream& out, const Date& adate) { out << adate.month << '/' << adate.day << '/' << adate.year % 100; return out; } // overloaded extraction operator function istream& operator>>(istream& in, Date& somedate) { in >> somedate.month; // accept the month part in.ignore(1); // ignore 1 character, the / character in >> somedate.day; // get the day part in.ignore(1); // ignore 1 character, the / character in >> somedate.year; // get the year part return in; } Date::Date(int mm, int dd, int yyyy) // constructor { month = mm; day = dd; year = yyyy; } int main() { Date a; cout << "Enter a date: "; cin >> a; // accept the date using cin cout << "The date just entered is " << a << endl; return 0; }