Computer Science - Object Oriented Programming Using C++ - Discussion

Discussion Forum : Object Oriented Programming Using C++ - Section 8 (Q.No. 12)
12.
A function that uses variable types is called __________
overloaded
a template function
a variable function
a virtual function
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
1 comments Page 1 of 1.

Ayesha... said:   5 years ago
A function that uses variable types is called A function that uses variable types is called
a template function.

template <template-parameters> function-declaration

The template parameters are a series of parameters separated by commas. These parameters can be generic template types by specifying either the class or typename keyword followed by an identifier. This identifier can then be used in the function declaration as if it was a regular type. For example, a generic sum function could be defined as:

template <class SomeType>
SomeType sum (SomeType a, SomeType b)
{
return a+b;
}.
template <template-parameters> function-declaration.

The template parameters are a series of parameters separated by commas. These parameters can be generic template types by specifying either the class or typename keyword followed by an identifier. This identifier can then be used in the function declaration as if it was a regular type.

For example, a generic sum function could be defined as:
template <class SomeType>
SomeType sum (SomeType a, SomeType b)
{
return a+b;
}

Post your comments here:

Your comments will be displayed after verification.