relational operators in class time
-
hello hello hello simply i have this code . and i need help to modify or change >= operators in class .
#include using namespace std ;
class time
{
private :
int hour ;
int minute ;
int second ;
public :
time ()
{}
time (int h , int m , int s ) : hour ( h) , minute (m) , second(s)
{}
void get ()
{
cin >> hour >> minute >> second ;
}
void show ()
{
cout << hour << " : " << minute << " : " << second << endl ;
}bool operator >= ( time r ) { if ( hour >= r.hour ) { if ( hour > r.hour ) { return true ; } else { if ( minute >= r.minute ) { if ( second >= r.second ) return true ; else return false ; } else { return false ; } } } else return false ; }
};
int main ()
{
time a, b ;
a.get() ;
b.get() ;a.show() ; b.show () ; if ( a >= b ) cout << "true \\n" ; else cout << "not true \\n" ; return 0 ;
}
-
hello hello hello simply i have this code . and i need help to modify or change >= operators in class .
#include using namespace std ;
class time
{
private :
int hour ;
int minute ;
int second ;
public :
time ()
{}
time (int h , int m , int s ) : hour ( h) , minute (m) , second(s)
{}
void get ()
{
cin >> hour >> minute >> second ;
}
void show ()
{
cout << hour << " : " << minute << " : " << second << endl ;
}bool operator >= ( time r ) { if ( hour >= r.hour ) { if ( hour > r.hour ) { return true ; } else { if ( minute >= r.minute ) { if ( second >= r.second ) return true ; else return false ; } else { return false ; } } } else return false ; }
};
int main ()
{
time a, b ;
a.get() ;
b.get() ;a.show() ; b.show () ; if ( a >= b ) cout << "true \\n" ; else cout << "not true \\n" ; return 0 ;
}
Change to what?