One of the greatest strengths of C++ is its support for generic programming. In generic programming, the algorithms and data structures are written in terms of generic types that will be specified later. This allows the programmer to implement a function or a class once, and later, instantiate it for many different types. Templates are a C++ feature that allows classes and functions to be defined on generic types. C++ supports three kinds of templates—function, class, and variable templates.
Templates in C++
Function templates
Function templates are generic functions—unlike the regular functions, a template function does not declare its argument types. Instead, the types are template parameters:
template <...