Using Templates

Publication: C++ Builder Developer's Journal
Issue: Volume 7, Number 6, June 2003

C++ is a strongly typed language and in this article I demonstrate the powerful concept of templates.

Templates are one of the most sophisticated and least understood features of the C++ language. Templates allow the creation of generic classes and functions that are independent of any data type. For example, a template function may accept parameters of any datatype. The first part of this article will introduce you to the concepts of function templates, offering an alternative to overloaded functions. The second part delves into class templates. The article has been structured this way so that you can not only learn the syntax of templates, but also how and when to use them and how they relate to other C++ language features and the VCL.