next up previous contents
Next: Tests and Accessors Up: Bank Keys Previous: Bank Keys

Initialization

Typically one initializes an instance of TRY_Bank_Key with a string for the bank name and an integer for the bank number, such as

TRY_Bank_Key my_bank_key("CMUO",5) ;

In most cases, however, one will simply pass the bank key as an argument to a function without bothering to store it explicitly in a named variable, such as

a_method( TRY_Bank_Key("CMUO",5) , ...) ;

Because it is so common that a method requires a bank key, but the user wishes to find the first bank matching a bank name with any bank number, the constructor

TRY_Bank_Key(const TRY_Bank_Name& name)

is not declared explicit. The C++ compiler will implicitly accept a bank name wherever a bank key is required, with the bank number set to the wildcard value. So, if a_method() does not take a TRY_Bank_Name for the first argument, and one wishes to indicate the first match with name ``CMUO'' with any number, then one can take advantage of implicit conversions of C-strings to TRY_Bank_Names, and of TRY_Bank_Names to TRY_Bank_Keys with TRY_Bank_Number set to wildcard, to shorten this line of code further by writing simply:

a_method( "CMUO" , ...) ;

One must use the default constructor in some cases, such as when declaring a built-in array of bank keys. Then the assign() method can be used to set the otherwise invalid bank key object to a valid key value, such as

TRY_Bank_Key my_bank_key ;      // Default constructor puts it in invalid state
my_bank_key.assign("CMUO",5) ;  // Now valid



Robert Kennedy
Mon Jul 28 13:23:28 CDT 1997