overload operators en cours

This commit is contained in:
Hugo LAMY
2022-02-16 13:48:33 +01:00
parent abb66473ab
commit d45a096244
6 changed files with 112 additions and 26 deletions

View File

@@ -94,24 +94,44 @@ Fixed & Fixed::operator=( Fixed const & rhs ) {
}
/*
* other operators
* operators < ; > ; <= ; == ; != ; + ; - ; * ; / ; ++ ; --
*/
//Fixed Fixed::operator+( Fixed const & rhs ) const {
// return Fixed( this->toFloat() + rhs.toFloat() );
//}
bool Fixed::operator< (Fixed const & rhs) const {
return this->toFloat() < rhs.toFloat();
}
bool Fixed::operator> (Fixed const & rhs) const {
return this->toFloat() > rhs.toFloat();
}
//Fixed operator> (Fixed const & rhs) const {
bool Fixed::operator<=(Fixed const & rhs) const {
return this->toFloat() <= rhs.toFloat();
}
bool Fixed::operator>=(Fixed const & rhs) const {
return this->toFloat() >= rhs.toFloat();
}
bool Fixed::operator==(Fixed const & rhs) const {
return this->toFloat() == rhs.toFloat();
}
bool Fixed::operator!=(Fixed const & rhs) const {
return this->toFloat() != rhs.toFloat();
}
Fixed Fixed::operator+ ( Fixed const & rhs ) const {
return Fixed( this->toFloat() + rhs.toFloat() );
}
Fixed Fixed::operator- ( Fixed const & rhs ) const {
return Fixed( this->toFloat() - rhs.toFloat() );
}
Fixed Fixed::operator* ( Fixed const & rhs ) const {
return Fixed( this->toFloat() * rhs.toFloat() );
}
Fixed Fixed::operator/ ( Fixed const & rhs ) const {
return Fixed( this->toFloat() / rhs.toFloat() );
}
//void Fixed::operator++( void ){
// this->_value += 1;
//}
//Fixed operator<=(Fixed const & rhs) const {
//}
//Fixed operator>=(Fixed const & rhs) const {
//}
//Fixed operator==(Fixed const & rhs) const {
//}
//Fixed operator!=(Fixed const & rhs) const {
//void Fixed::operator--( void ){
// this->_value -= 1;
//}