Currency Module Examples
Table 2 lists the example programs and briefly describes what they do.
 
Table 2 – Example programs 
Name
Description
currexam.cpp
A very simple example using the RWCurrencyBook class. The example illustrates how to initialize a currency book object from a file and how to access currency information using it.
example1.cpp
A very simple example illustrating how decimals give exact results, whereas floating-point values have built-in rounding errors.
factoryexam.cpp
An example illustrating the use of the class RWExchangeFactory.
A factory contains an exchange rate table and at least one exchange group. Exchange groups can construct exchange objects, which are used to perform currency conversions. When presented with a source/target currency pair, the exchange factory searches its list of exchange groups until it finds a group that can create an exchange object given the source/target pair and the factory's associated exchange rate table. If no group can create such an object, the factory returns an invalid object.
format1.cpp
Simple example illustrating that the RWDecimalFormat class can be used to do simple formatting of RWMoney objects.
format2.cpp
An example of how to format a large data set of money. A sales report is generated in two different styles using the same data.
groupexam.cpp
Illustrates the use of exchange groups and of RWExchangeFactory.

A factory contains an exchange rate table and at least one exchange group. Exchange groups can construct exchange objects, which are used to perform currency conversions. When presented with a source/target currency pair, the exchange factory searches its list of exchange groups until it finds one that can create an exchange object given the source/target pair and the factory's associated exchange rate table. If no group can create such an object, an invalid object is returned.
In this example, an exchange factory object is created and three exchange groups are added including our own creation, a US dollar base group. Several currency exchanges are performed.
calcexam.cpp
Reads in an RWExchangeRateTable and RWEuroGroup to construct an RWExchangeFactory. This factory is then associated with an RWMoneyCalculator. The calculator is used to perform arithmetic with different currency conversion policies and rounding methods.
savings.cpp
Demonstrates how a savings account grows. Shows how to use the RWDecimal class.