Currency Information Class
The currency class is called
RWCurrency, and it stores the following currency information:
Mnemonic. The mnemonic uniquely identifies the currency. Defined in the ISO 4217:1995 standard.
Name. The name uniquely identifies the currency. Defined in the ISO 4217:1995 standard.
Numeric Code. The numeric code uniquely identifies the currency. Defined in the ISO 4217:1995 standard.
Fraction Name. The name of the fraction part of the currency. Examples of fraction names are “Cents” for United States “Dollar” and “Pence” for United Kingdom “Pound.”
Ratio of Whole to Fraction. The ratio between one unit of the whole part of the currency and the smallest unit of the fractional part of the currency. For United States Dollars, the ratio is one dollar to one penny or 0.01.
Introduction Date. Date that the currency was (or will be) introduced.
Expiration Date. Date upon which the currency is no longer valid.
Notice that the currency information class does not contain information about the relative value of a currency to any other currency, nor does it specify any amounts. Money classes, described in
Chapter 4, Money and Calculations, provide a mapping between a currency and an amount. A variety of currency exchange classes, described in
Chapter 5, Currency Conversions, provide methods for converting from one currency to another.
When you construct a currency object, the introduction and expiration dates are optional. For example the following line creates an
RWCurrency object,
USDollars:
RWCurrency USDollars(“USD”, 840, “dollar”, “cents”, 0.01);
When you omit the introduction and expiration dates they are replaced with two public static data members:
RWCurrency::noIntroductionDate and
RWCurrency::noExpirationDate. The data member
noIntroductionDate represents a date that is before January 1, 1000. Similarly,
noExpirationDate represents December 25, 9999. You can also use these data members in code to determine whether a currency object has an introduction of expiration date. The entry for
RWCurrency in the
SourcePro API Reference Guide contains an example showing how the data members work.