Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Currency Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

2.10 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.

2.10.1 Building and Running the Currency Examples

For information about compiling the currency examples, see Installing and Building Your SourcePro C++ Products, available at buildspace\docs\html\rcbug\index.html. The example executables can be found in the directory of your buildspace. Change to the appropriate directory and type the example's file name to run the example.



Previous fileTop of DocumentContentsIndex pageNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.