#include #include #include using namespace std; #include "Date.h" int another_function(); int main() { int aMonth = 5, aDay = 27, aYear = 2009; // Create a Date object: Date today( aMonth, aDay, aYear ); // this calls the Date() constructor // that has 3 integer arguments Date d(); int x = another_function(); cout << "Today's date is: "; today.print(); cout << endl; today.increment(); cout << "Today is now tomorrow: "; today.print(); cout << endl; Date bday( 5, 2, 1973 ); for ( int i = 0 ; i < 365 ; i++ ) { cout << "Next day: "; today.increment(); today.print(); if ( bday.isEqual( today ) ) { cout << " (my birthday!)"; } if ( sameDayAndMonth( today, bday ) ) { cout << " (happy birthday!)"; } cout << '\n'; } vector v; v.push_back( Date( 4, 10, 1988 ) ); v.push_back( Date( 2, 28, 2002 ) ); v.push_back( today ); v.push_back( bday ); for ( int i = 0 ; i < v.size() ; i++ ) { v[i].print(); cout << ' '; } cout << endl; // TODO: sort the vector.... // sort( v.begin(), v.end(), isLessThan ); sort( v.begin(), v.end() ); if ( v[0] < v[1] ) { cout << "Looks like the sort worked." << endl; } for ( int i = 0 ; i < v.size() ; i++ ) { v[i].print(); cout << ' '; } cout << endl; Date d1( 6, 4, 2009 ); cout << d1 << '\n'; Date d2 = d1 + 60; cout << d1 << " plus 60 days is " << d2 << '\n'; Date d3 = d2 - 59; cout << d2 << " minus 59 days is " << d3 << '\n'; Date d4 = d3++; // postfix // Date d4 = d3; d3++; cout << d3 << ' ' << d4 << '\n'; Date d5 = ++d2; // prefix // ++d2; Date d5 = d2; cout << d2 << ' ' << d5 << '\n'; Date d6 = d5; // d6.operator=(d5) // we don't need to // implement this one // (default copies all // member variables) if ( d6 == d5 ) { cout << "same dates (no surprise)\n"; } return 0; }