Template is a feature of C++ where it provides us to define function (or class) without specifying types at that moment. Based on the usage, compiler can then create those functions (or classes) with the actual types.

It helps us to avoid creating same functions for different types as done for function overloading. Let the compiler do this task for us!

References

  1. https://www.learncpp.com/cpp-tutorial/function-templates/