Function Templates - Function and Method

Q.  Function Templates can have
- Published on 19 Oct 15

a. Explicit instantiation definition with template argument for all parameters
b. explicit instantiation of declaration with template argument for all parameters
c. Both a and b
d. None

ANSWER: Both a and b
A function template cannot be defined as a type or a function in itself. There is no such coding available that contains only template definitions generated from a source file. A template must have real instance i.e. template arguments must be determined such that the compiler generates an actual function. Here both first and second options are correct. An explicit formation of instance definition forces instantiation of member functions. For instantiating a function template all template arguments must be known.

Post your comment / Share knowledge

Enter the code shown above:
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)