Consider the following class Date, which represents a date using three ints for month, day and year: class Date { private: int month; int day; int year; public: Date() { month = day = year = 0; } Date(int m, int d, int y) { month = m; day = d; year = y; } bool operator==(Date); bool operator<(Date); }; Write an implementation for both overloaded operators. == should return true if the Date objects are equivalent and false if not. < should return true if the Date of the calling object (left object) comes before the parameter Date object (right object) and false if not. You may assume that all objects of class Date are valid, i.e. month is between 1 and 12, inclusive; day contains an appropriate day for the given month, and year can be anything. You do not need to demonstrate calling these operators.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Consider the following class Date, which represents a date using three ints for month, day and year:
class Date
{
private:
int month;
int day;
int year;
public:
Date() { month = day = year = 0; }
Date(int m, int d, int y) { month = m; day = d; year = y; }
bool operator==(Date);
bool operator<(Date);
};
Write an implementation for both overloaded operators. == should return true if the Date objects are equivalent and false if not. < should return true if the Date of the calling object (left object) comes before the parameter Date object (right object) and false if not.
You may assume that all objects of class Date are valid, i.e. month is between 1 and 12, inclusive; day contains an appropriate day for the given month, and year can be anything.
You do not need to demonstrate calling these operators.
Step by step
Solved in 3 steps with 1 images