#include #include // class declaration class Date { private: int month, day, year; public: Date(int = 7, int = 4, int = 2001); // constructor operator long(); // conversion operator function void showdate(); }; // implementation section // constructor Date::Date(int mm, int dd, int yyyy) { month = mm; day = dd; year = yyyy; } // conversion operator function converting from Date to long Date::operator long() // must return a long { long yyyymmdd; yyyymmdd = year * 10000.0 + month * 100.0 + day; return(yyyymmdd); } // member function to display a date void Date::showdate() { cout << setfill('0') << setw(2) << month << '/' << setw(2) << day << '/' << setw(2) << year % 100; cout << endl; return; } int main() { Date a(4,1,1999); // declare and initialize one object of type date long b; // declare an object of type long b = a; // a conversion takes place here cout << "a's date is "; a.showdate(); cout << "This date, as a long integer, is " << b << endl; return 0; }