.
To use this class, you'd have class CUSTOMER inherit from class MATCHABLE, which contains the code that verifies that a given class contains only members starting with, say, an integer. The list is declared this way:
customers:KEY_LIST[CUSTOMER]
. The relationship of these classes is
shown in the figure
(the root class BANK is the class that calls objects and starts the whole bank program off).
C++ can enforce similar restrictions for generic classes, but they are not stated explicitly, as they are in Eiffel. Instead, a C++ compiler does not verify that a parameter type is supported until a client creates an instance of a generic class. The only possible way to check for proper use of generic classes is for the programmer to closely examine the code line by line.
illustration_link (11 Kbytes)

CUSTOMER inherits its type-validation code from MATCHABLE and becomes the parameter used to constrain the generic class KEY_LIST. The latter is a container class whose members all begin with a key (e.g., an integer).