Share via


COleCurrency::operator +, -

These operators allow you to add and subtract two COleCurrency values to and from each other and to change the sign of a COleCurrency value.

COleCurrency operator +( 
   const COleCurrency& cur  
) const; 
COleCurrency operator -( 
   const COleCurrency& cur  
) const; 
COleCurrency operator -( ) const;

Remarks

If either of the operands is null, the status of the resulting COleCurrency value is null.

If the arithmetic operation overflows, the resulting COleCurrency value is invalid.

If the operand is invalid and the other is not null, the status of the resulting COleCurrency value is invalid.

For more information on the valid, invalid, and null status values, see the m_status member variable.

Example

// 35.0050
COleCurrency cur1(35, 50);
// 2.0075
COleCurrency cur2(2, 75);
COleCurrency cur3;

// sum is 37.0125
cur3 = cur1 + cur2;
ASSERT(cur3 == COleCurrency(37, 125));

// difference is 32.9975
cur3 = cur1 - cur2;
ASSERT(cur3 == COleCurrency(32, 9975));

Requirements

Header: afxdisp.h

See Also

Reference

COleCurrency Class

Hierarchy Chart

COleCurrency::operator +=, -=

COleCurrency::GetStatus