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

Initialization

Typically one initializes an instance of TRY_Bank_Name with a 4 character C-string, such as

TRY_Bank_Name my_bank_name("CMUO") ;

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

a_method( TRY_Bank_Name("CMUO") , ...) ;

In fact, if a_method() does not take a C-string for the first argument, then one can take advantage of an implicit conversion of C-strings to TRY_Bank_Names 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 names. Then an assign() method can be used to set the otherwise invalid bank name object to a valid name, such as

TRY_Bank_Name my_bank_name ;    // Default constructor puts it in invalid state
my_bank_name.assign("CMUO") ;   // Now valid

Note that a C-string initial value is portable across different computing platforms. The integer initial value for the same bank name would vary in byte order between big-endian systems (SGI, AIX, Sun, Mac-based Linux) and little-endian systems (DEC, Intel-based Linux). Because of this, support for the integer representation is deprecated; it may be removed from the class in the future.



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