Jun 15 in C++

Q: What is a template?

1 Answer

Jun 16

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.

Click here to read more about C++
Click here to read more about Insurance

Related questions

Jun 15 in C++
Jun 11 in C++
Jun 9 in C++