<<< Template philosophy | Index | Default template arguments >>> |
Templates can have more than one argument.
Templates can have different kinds of arguments.
Non-class arguments must be supplied with constants:
template< typename ValueT, int SIZE >
class FixedSizeBuffer {
ValueT m_buffer[ SIZE ];
int m_size;
public:
FixedSizeBuffer() : m_size( SIZE ) {}
};//class FixedSizeBuffer
FixedSizeBuffer< char, 80 > line; // ValueT is char, SIZE is 80
FixedSizeBuffer< string, 10 > sb; // ValueT is string, SIZE is 10
<<< Template philosophy | Index | Default template arguments >>> |