Templates provide a way to make a class, function, or variable operate with different data types without having to rewrite the code for each type.
Function Templates
This example shows a function that swaps two integer arguments.
To convert this method into a function template that can work with any type, the first step is to add a template parameter declaration before the function. This declaration includes the template keyword followed by the keyword class and the name of the template parameter, both enclosed between angle brackets. ...