C++

Topic: Templates

What is a template?

Templates allow to create generic functions that admit any data type as parameters and return value<br>without having to overload the function with all the possible data types. Until certain point they fulfill<br>the functionality of a macro. Its prototype is any of the two following ones:<br><br>template <class indetifier> function_declaration; template <typename indetifier><br>function_declaration;<br><br>The only difference between both prototypes is the use of keyword class or typename, its use is<br>indistinct since both expressions have exactly the same meaning and behave exactly the same way.

Browse random answers: