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

Quang Hiếu

New member
What does this template function indicates?
Code:
==================
template<class T>
T 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: a
Explanation: As the return type of function is template T, therefore, the function is returning a general type. 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