#include #include #include using namespace std; class date { public: int year; int month; int day; void print() const; void next(int n); void next(); void prev(int n); void prev(); }; int main() { const date independenceDay {1777, 7, 4}; independenceDay.print(); cout << " is Independence Day.\n"; const time_t t {time(nullptr)}; const tm *const p {localtime(&t)}; const date today {p->tm_year + 1900, p->tm_mon + 1, p->tm_mday}; today.print(); cout << " is today.\n"; date tomorrow {today}; tomorrow.next(); tomorrow.print(); cout << " is tomorrow.\n"; date christmas {today}; christmas.next(329); christmas.print(); cout << " is next Christmas.\n"; date testDate {2025, 3, 1}; cout << "Original date: "; testDate.print(); cout << "\n"; testDate.prev(); cout << "After going 1 day into the past: "; testDate.print(); cout << "\n"; return EXIT_SUCCESS; } const int date_length[] { 0, 31, //January 28, //February(disregarding leap year) 31, //March 30, //April 31, //May 30, //June 31, //July 31, //August 30, //September 31, //October 30, //November 31 //December }; void date::print() const { cout << month << "/" << day << "/" << year; } void date::next(int n) { for (int i {0}; i < n; ++i) { next(); } } void date::next() { if (day < date_length[month]) { ++day; } else { day = 1; if (month < 12) { ++month; } else { month = 1; ++year; } } } void date::prev(int n) { for (int i {0}; i < n; ++i) { prev(); } } void date::prev() { if (day > 1) { --day; } else { if (month > 1) { --month; day = date_length[month]; } else { month = 12; --year; day = date_length[month]; } } }