Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

5.1 Introduction

In order to perform a currency conversion, you need to know which currency you're converting from, which currency you're converting to, what exchange rate you should use, and how you should apply that exchange rate. Money.h++ ties all these pieces of the conversion process together.

First, Money.h++ provides a way to define exchange rates and to build a table of those exchange rates. These objects, and some examples of the processes used to create them, are described in Section 5.2.

After you determine the exchange rates, you need to tie them to the processes that will be used to perform the conversions from one currency to another. The classes that let you convert money are called currency exchange classes. Money.h++ uses a handle/body design for these classes so that all of them provide a common API, even though they may implement different conversion methods. Currency exchange classes can be categorized into currency exchange groups according to the type of conversion process they employ. Currency exchange groups bind a particular conversion process to a set of exchange rates. For example, Money.h++ provides a multiplication exchange group that binds exchange rates to a process that multiplies a source currency by an exchange rate to result in a target currency. Section 5.3 describes the design of the exchange classes and Section 5.4 describes the exchange groups supplied by Money.h++.

A currency exchange factory lets your programs automatically create an exchange object with which to perform a currency conversion. By setting up an appropriately-designed exchange factory, you don't need to think about what type of exchange object you're using to perform a conversion--if an exchange rate for the currencies you've named exists, the exchange object will be created. Section 5.5 provides examples of setting up an exchange factory.

Section 5.6 and Section 5.7 provide C++ and Java code for some example conversions, andSection 5.8 describes how to customize exchange objects. Finally, Section 5.9 and Section 5.10 provide diagrams of the class hierarchies described in this chapter.


Previous fileTop of DocumentContentsIndexNext file

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