Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Pro Android Graphics

Authors: Wallace Jackson

1st Edition

1430257857, 978-1430257851

More Books

Students also viewed these Programming questions

Question

Explain the importance of Human Resource Management

Answered: 1 week ago