Question
Overload relational operator greater than operator> that can be used with the Date class. Test your new operators in the main problem. #include using
Overload relational operator greater than " operator>" that can be used with the Date class. Test your new operators in the main problem.
#include using namespace std;
class Date { // data declaration section private: int month; int day; int year;
// method declarations public: Date(int = 7, int = 4, int = 2005); // constructor int operator==(Date &); // declare the operator== function int operator>(Date &); int operator(date> };
// implementation section
Date::Date(int mm, int dd, int yyyy) { month = mm; day = dd; year = yyyy; }
int Date::operator==(Date &date2) { if(day == date2.day && month == date2.month && year == date2.year) return 1; else return 0; }
int main() { Date a(4,1,2007), b(12,18,2008), c(4,1,2007); // declare 3 objects
if (a == b) cout else cout
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started