Technical Discussion :: C++
Home > Technical Interview Q&A > C++ > Discussion
106 / 187
What is function templates?
Answer:
Like class template, we can also define function templates that would be used to create a family of function with different argument types.
Syntax:
Template
return type function name(argument of type T)
{
………..
//body of function
//with type T
//wherever appropriate
}
We must use the template parameter T as and when necessary in the function body and in its arguments list.
Asked In ::
Sasi
23 Feb, 2019 5:07 AM
Like class template, we can also define function templates that would be used to create a family of function with different argument types.
Syntax:
Template
return type function name(argument of type T)
{
………..
//body of function
//with type T
//wherever appropriate
}
We must use the template parameter T as and when necessary in the function body and in its arguments list.
Syntax:
Template
return type function name(argument of type T)
{
………..
//body of function
//with type T
//wherever appropriate
}
We must use the template parameter T as and when necessary in the function body and in its arguments list.