#include #include // class declaration class Date { private: int month; int day; int year; public: Date(int = 7, int = 4, int = 2001); // constructor with defaults void setdate(int, int, int); // member function to copy a date void showdate(); // member function to display a date }; // implementation section Date::Date(int mm, int dd, int yyyy) { month = mm; day = dd; year = yyyy; } void Date::setdate(int mm, int dd, int yyyy) { month = mm; day = dd; year = yyyy; return; } void Date::showdate() { cout << "The date is "; cout << setfill('0') << setw(2) << month << '/' << setw(2) << day << '/' << setw(2) << year % 100; // extract the last 2 year digits cout << endl; return; } int main() { Date a, b, c(4,1,1998); // declare 3 objects - initializes 1 of them b.setdate(12,25,2002); // assign values to b's data members cout << endl; a.showdate(); // display object a's values b.showdate(); // display object b's values c.showdate(); // display object c's values return 0; }