Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

5.3 Currency Exchange Classes

Money.h++ provides three different conversion methods:

The C++ class RWExchange contains a pointer to implementation class of type RWExchangeImpl, and defers to that implementation when actually performing a currency conversion. Money.h++ provides three C++ currency exchange classes, corresponding to the conversion methods listed above, that derived from the abstract base class RWExchangeImpl. The three exchange classes are implementation classes of class RWExchange, which presents a generic interface for performing currency exchanges.

The different implementations share an interface, but work differently from one another. For example, an RWExchange object that contains an RWMultiplicationExchange implementation performs a currency exchange by invoking an implementation multiplies the amount in the source currency by a conversion factor to get the amount in the target currency.

Contrast this with an RWExchange object that contains an RWTriangularExchange implementation. RWTriangularExchange invokes an implementation that converts the source currency to a base currency, then converts the base currency to the target. First, the RWTriangularExchange implementation converts the source to the base by dividing the source by a base-to-source conversion factor. Then it multiplies the result by a base-to-target conversion factor to obtain the target. This is the algorithm mandated by the European Monetary Union (EMU) for converting between local EMU currencies during the Euro transition period.

In Java, MultiplicationExchange and DivisionExchange inherit directly from abstract base class BilateralExchange. Class BilateralExchange and class TriangularExchange both inherit from the abstract base class Exchange.


Previous fileTop of DocumentContentsIndexNext file

©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.