I am new to overloading operators. I am trying to overload a bool operator. I am currently using the bool operator as an access function into the Date class. Any suggestions how I would go about converting the bool EqualTo function to overload the operator? Thank you!
class Date {
private:
int mn; //month component of a date
int dy; //day component of a date
int yr; //year comonent of a date
public:
//constructors
Date() : mn(0), dy(0), yr(0)
{}
Date(int m, int d, int y) : mn(m), dy(d), yr(y)
{}
//access functions
int getDay() const
{
return dy;
}
int getMonth() const
{
return mn;
}
int getYear() const
{
return yr;
}
bool EqualTo(Date d) const;
};
bool Date::EqualTo(Date d) const
{
return (mn == d.mn) && (dy == d.dy) && (yr == d.yr);
}