From 8ec6b3493dbc2cdbaf456eae3d0a866c0ebae0e4 Mon Sep 17 00:00:00 2001 From: Eivind Kvedalen Date: Tue, 3 Feb 2015 00:25:03 +0100 Subject: [PATCH] Added Quantity::operator>(...). --- src/Base/Quantity.cpp | 8 ++++++++ src/Base/Quantity.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/Base/Quantity.cpp b/src/Base/Quantity.cpp index 393632d59844..4bb599c5e024 100644 --- a/src/Base/Quantity.cpp +++ b/src/Base/Quantity.cpp @@ -79,6 +79,14 @@ bool Quantity::operator <(const Quantity& that) const return (this->_Value < that._Value) ; } +bool Quantity::operator >(const Quantity& that) const +{ + if(this->_Unit != that._Unit) + throw Base::Exception("Quantity::operator >(): quantities need to have same unit to compare"); + + return (this->_Value > that._Value) ; +} + Quantity Quantity::operator *(const Quantity &p) const { return Quantity(this->_Value * p._Value,this->_Unit * p._Unit); diff --git a/src/Base/Quantity.h b/src/Base/Quantity.h index b11d6f974348..4c4edacd8c55 100644 --- a/src/Base/Quantity.h +++ b/src/Base/Quantity.h @@ -58,6 +58,7 @@ class BaseExport Quantity Quantity operator /(const Quantity &p) const; bool operator ==(const Quantity&) const; bool operator < (const Quantity&) const; + bool operator > (const Quantity&) const; Quantity& operator =(const Quantity&); Quantity pow(const Quantity&)const; //@}