Same-Currency Calculations
RWMoney<T> provides global operators for performing same-currency arithmetic calculations. When objects created from these classes are used in arithmetic operations, all operands must be the same currency. If the currencies for operands in the same equation differ, the operator throws an exception.
Similarly, all assignments to money objects must have the same currency as the original object. If not, an exception is thrown.
Here is an example:
.
.
.
RWMoney<RWDecimal64> x("1.23","USD"), y("9.87","USD"),
z("7.99","CAD");
RWMoney<RWDecimal64> s("0","USD");
s = x + y; // Okay, same currencies
s = y - z; // Error, different currencies. Exception thrown.
s = x; // Okay, same currencies
s = z; // Error, different currencies. Exception thrown.
 
.
.
.