in C Plus Plus by
What is a template?

▼ Show 1 Answer

0 votes

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.

Learn More with Madanswer

Related questions

0 votes
asked Jun 9, 2020 in C Plus Plus by Robindeniel