Function Templates(C++ Programming ) Questions and Answers
Explanation:-
Answer: Option C. -> constant expressionNon-type template parameters provide the ability to pass a constant expression at compile time.
The constant expression may also be an address of a function, object or static class member.
Explanation:-
Answer: Option C. -> constant expressionAnswer:d
Explanation:In this program, We are using the for loop to increment the value by 1 in the function template.
Output:
$ g++ ftemp5.cpp
$ a.out
2.1
3.1
4.1
Explanation:-
Answer: Option C. -> constant expressionAnswer:a
Explanation:In this program, We are passing the values and calculating the square of the value by using the function template.
Output:
$ g++ ftemp4.cpp
$ a.out
2 4
2.2 4.84
Explanation:-
Answer: Option B. -> 200In this program, We are using class to pass the value and then we are manipulating it.
Output:
$ g++ ftemp3.cpp
$ a.out
200