0 votes
in C Plus Plus by
What is a template?

1 Answer

0 votes
by

Templates allow creating functions that are independent of data type (generic) and can take any data type as parameters and return value without having to overload the function with all the possible data types. Templates nearly fulfill the functionality of a macro.

Its prototype is any of the following ones:

template <class identifier> function_declaration;

template <typename identifier> function_declaration;

The only difference between both the prototypes is the use of keyword class or typename. Their basic functionality of being generic remains the same.

...