Quantity: Added -= and += operators.
This commit is contained in:
@@ -113,6 +113,17 @@ Quantity Quantity::operator +(const Quantity &p) const
|
||||
throw Base::Exception("Quantity::operator +(): Unit mismatch in plus operation");
|
||||
return Quantity(this->_Value + p._Value,this->_Unit);
|
||||
}
|
||||
|
||||
Quantity& Quantity::operator +=(const Quantity &p)
|
||||
{
|
||||
if(this->_Unit != p._Unit)
|
||||
throw Base::Exception("Quantity::operator +=(): Unit mismatch in plus operation");
|
||||
|
||||
_Value += p._Value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Quantity Quantity::operator -(const Quantity &p) const
|
||||
{
|
||||
if(this->_Unit != p._Unit)
|
||||
@@ -120,6 +131,16 @@ Quantity Quantity::operator -(const Quantity &p) const
|
||||
return Quantity(this->_Value - p._Value,this->_Unit);
|
||||
}
|
||||
|
||||
Quantity& Quantity::operator -=(const Quantity &p)
|
||||
{
|
||||
if(this->_Unit != p._Unit)
|
||||
throw Base::Exception("Quantity::operator -=(): Unit mismatch in minus operation");
|
||||
|
||||
_Value -= p._Value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Quantity Quantity::operator -(void) const
|
||||
{
|
||||
return Quantity(-(this->_Value),this->_Unit);
|
||||
|
||||
Reference in New Issue
Block a user