What does this template function indicates? [code] ================== template<class T> void func(T a) { cout<<a; } ==================[/code]

Thu Ha

New member
What does this template function indicates?
Code:
==================
template<class T>
void func(T a)
{
	cout<<a;
}
==================
A. A function taking a single generic parameter and returning a generic type
B. A function taking a single generic parameter and returning nothing
C. A function taking single int parameter and returning a generic type
D. A function taking a single generic parameter and returning a specific non-void type
 
Answer: b
Explanation: As the return type of function is void therefore function is not returning anything. Now as the function is taking a template T as its argument which is a general type, therefore, it is accepting a single general type argument.
 

Tìm kiếm

Back
Top