Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a c++ program. a. Add a new function to the class Date that returns the month in letters (e.g., January, February, etc.). b. Add

Create a c++ program.

a. Add a new function to the class Date that returns the month in letters (e.g., January, February, etc.).

b. Add a function that displays Happy New Year! when the data is January 1.

c. Add a function that compares two dates.

d. Test the new functions of the class Date by creating dynamically (i.e., using pointers) two objects of the class Date and invoking the new member functions on both objects.

/* date.h */ #ifndef DATE_H_ #define DATE_H_ class Date { public: Date(int=1, int=1, int=2000); // sets day, month, year void setDate(int, int, int); // sets the date void printDate() const; // prints date to the screen private: int day; int month; int year; }; #endif /* DATE_H_ */ /* date.cpp */ #include #include "date.h" using namespace std; // Constructor Date::Date (int d, int m, int y) { day = d; month = m; year = y ; } // sets date void Date::setDate(int d, int m, int y) { day = d; month = m; year = y ; } // prints date void Date::printDate() const { cout << month << "/" << day << "/" << year << " "; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions