C++ function templates are used to write generic functions. A generic function defines a family of functions which are defined using the same code but which can be parameterized by different types, and by some sorts of constant parameters.

The classic example is a **max** function which returns the greater of its two parameters :-

template<class T>
T max(T a, T b) {
return (a<b?a:b);
}

This function can be used for any pair of parameters of the same type provided that the **<** operator is defined for them.