//This file is main.C #include #include #include "date.h" using namespace std; int main() { const int len[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int status = EXIT_SUCCESS; int n1 = 0; for (int year1 = 1901; year1 <= 1910; ++year1) { cout << year1 << "\n"; //Assure the user that we're making progress. for (int month1 = 1; month1 <= 12; ++month1) { for (int day1 = 1; day1 <= len[month1]; ++day1, ++n1) { const date d1(month1, day1, year1); int n2 = 0; for (int year2 = 1901; year2 <= 1910; ++year2) { for (int month2 = 1; month2 <= 12; ++month2) { for (int day2 = 1; day2 <= len[month2]; ++day2, ++n2) { const date d2(month2, day2, year2); const int dist = n1 - n2; if (distance(d1, d2) != dist) { cout << "distance("; d1.print(); cout << ", "; d2.print(); cout << ") == " << distance(d1, d2) << ", but should have been " << dist << ".\n"; status = EXIT_FAILURE; goto done; } } } } } } } done:; return status; }