Professional Documents
Culture Documents
3 Function Templates
Example
Function Templates
When the template function is called at that moment, from the type
of argument passed to the template function, the compiler identifies
the data type.
Then, every argument of template type is replaced with the identified
data type; this process is called instantiating.
Thus, according to different data types, respective versions of the
template function are created.
Though the template function is compatible for all data types, it will
not save any memory.