Quantity: Added -= and += operators.
This commit is contained in:
parent
0e45008f9a
commit
d6052a5a27
|
@ -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);
|
||||
|
|
|
@ -53,7 +53,9 @@ public:
|
|||
//@{
|
||||
Quantity operator *(const Quantity &p) const;
|
||||
Quantity operator +(const Quantity &p) const;
|
||||
Quantity& operator +=(const Quantity &p);
|
||||
Quantity operator -(const Quantity &p) const;
|
||||
Quantity& operator -=(const Quantity &p);
|
||||
Quantity operator -(void) const;
|
||||
Quantity operator /(const Quantity &p) const;
|
||||
bool operator ==(const Quantity&) const;
|
||||
|
|
Loading…
Reference in New Issue
Block a user