#include "stdstuff.h" #include "Date.h" int main () { Date d, d2; int days; char day_names [][10] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }; // If the following is included, the constructor will quit. // Date dummy (-1, -1, -1); for (;;) { cout << "Enter dd mm yyyy (invalid values to terminate): "; d.read (cin); if (cin.fail()) { pause(); return 0; } cout << "Enter days to move date forward (may be -ve): "; cin >> days; d.move (days); // if something goes wrong, program aborts cout << "The new date is "; d.write (cout); cout << ". That is a " << day_names[d.dayInWeek()- 1] << ".\n"; // a simple example of using a function which returns a date d2 = d.nextDay(); // if something goes wrong, program aborts cout << "The day after that is "; d2.write(cout); cout << endl; // a trickier way of doing the same thing cout << "The day after that is "; d.nextDay().write(cout); // again, if something goes wrong, program aborts cout << endl; cout << "Comparing that day with the next day produces " << d.compareTo(d.nextDay()) << endl; } pause (); return 0; }