Working with overloading unary, binary, etc etc operators

We are using classes to do this, based on Times.

My << operator is suppose to output each Data Member of the class while calling a reduce function. However everything is required to be a const so my reduce function can't change it.

My second issue is with my != function. I may be missing the obvious but I can't get it to work.

Below are my cpp file with function definitions and header file with the class and function prototypes.

Code:Time.cpp #include "Time.h" #include <iostream> using namespace std; ostream& operator << (ostream& ostr, const Time& rhs) { ostr << rhs.Hour.Reduce() << ":" << rhs.Minute.Reduce() << ":" << rhs.Second.Reduce(); return ostr; } istream& operator >> (istream& istr, Time& rhs) { istr >> rhs.Hour >> rhs.Minute >> rhs.Second; return istr; } Time::Time() { Hour = 0; Minute = 0; Second = 0; } Time::Time(int H, int M, double S) { Hour = H; Minute = M; Second = S; } Time::Time(const Time& V) { Hour = V.Hour; Minute = V.Minute; Second = V.Second; } const Time Time::operator + (const Time& rhs) const { return Time( Hour + rhs.Hour, Minute + rhs.Minute, Second + rhs.Second); } const Time Time::operator - (const Time& rhs) const { return operator + ( -rhs ); } const Time Time:: operator - () const { return Time(-Hour,Minute,Second); } const Time Time::operator + () const { return *this; } const bool Time::operator < (const Time& rhs) const { return (Hour < rhs.Hour) || (Hour <= rhs.Hour && Minute < rhs.Minute) || (Hour <= rhs.Hour && Minute <= rhs.Minute && Second < rhs.Second); } const bool Time::operator == (const Time& rhs) const { return (Hour == rhs.Hour && Minute == rhs.Minute && Second == rhs.Second); } const bool Time::operator <= (const Time& rhs) const { return operator < (rhs) || operator == (rhs ); } const bool Time::operator > (const Time& rhs) const { return !(operator <= (rhs) ) ; } const bool Time::operator >= (const Time& rhs) const { return operator > (rhs) || operator == (rhs) ; } const Time Time::operator = (const Time& rhs) { Hour = rhs.Hour; Minute = rhs.Minute; Second = rhs.Second; return rhs; } const bool Time::operator != (const Time& rhs) const { return !(operator == rhs()); } const Time Time::operator ++ () { operator = (operator + (Time(1,1,1))); return *this; } const Time Time::operator ++ (int) { Time Tmp(*this); operator = ( operator + (Time(1,1,1))) ; return Tmp; } void Time::Reduce() { int count; count = static_cast <int> (Second) / 60; Second = static_cast <int> (Second) % 60; Minute += count; count = Minute / 60; Minute = Minute % 60; Hour += count; Hour = Hour % 24; }Thanks in advance for any advice/assistanceCode:Time.h #include <iostream> using namespace std; class Time { private: int Hour; int Minute; int Second; void Reduce(); public: Time(); Time(int H, int M, double S); Time(const Time& V); const Time operator + (const Time& rhs) const ; //Add two times const Time operator - (const Time& rhs) const ; //sub two times const bool operator < (const Time& rhs) const; // < two times const bool operator == (const Time& rhs) const; // == two times const bool operator <= (const Time& rhs) const; // <= two times const bool operator > (const Time& rhs) const; // > two times const bool operator >= (const Time& rhs) const; // > two times const bool operator != (const Time& rhs) const; const Time operator = (const Time& rhs); // assignment times const Time operator - () const; const Time operator + () const; const Time operator ++ (); const Time operator ++ (int); friend ostream& operator << (ostream& ostr, const Time& rhs); friend istream& operator >> (istream& istr, Time& rhs); };