It is an approach where generic types are used as parameters in algorithms so that they work for a variety of suitable data types and data structures.
Class template- For eg. An array class for multiple data types(int , float etc.).
Function template- For eg. A function mul() for multiplying int, float, double data types.
A template is a mechanism that allows you to create functions and classes that can be reused with every data types.
Template is defined with a parameter that would be replaced, the templates are sometimes called as parameterized classes or functions.
Void swap(T &x, T &y)
T temp= x;
Void fun(int m, int n,float a, float b)