 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
Clients
must specify the values for non-type identifiers
|
|
|
explicitly
inside of angle brackets when
defining objects
|
|
class
templates.
|
|
//function template declaration
|
|
template <char non_type, class
TYPE_ID>
|
|
class t_class {
|
|
public:
|
|
TYPE_ID function(int TYPE_ID);
|
|
};
|
|
//client code
|
|
t_class <'\n',int> obj;
|
|
| • |
Using
non-type formal arguments allows the client to
|
|
|
specify
at compile time some constant expression when
|
|
|
defining
an object, which can be used by the class to
|
|
|
initialize
constants, determine the size of statically
|
|
|
allocated
arrays, or any other initialization.
|
|