> Question 34) Choose the correct statement:
A) Delcaring a function with a default arguments: void f(int a = 1, int b);
Correct only if the function had been declared earlier, in the same scope, with a default for the second argument.
B) When overloading a function: the type and or number of parameters in each version must be different
Correct only if none of the overloaded function are explicit instantiations of function templates.
For instance:
1 2 3 4 5 6 7 8 9 10 11 12
|
#include <iostream>
template < typename T > void foo( T ) { std::cout << "template\n" ; }
void foo( int ) { std::cout << "non-template\n" ; }
template void foo<int>( int ) ; // fine: explicit instantiation of void foo(int)
int main()
{
foo(7) ; // non-template
foo<int>(7) ; // template
}
|
C) When overloading a function: the return type in each version must be different
Incorrect
D) 1. When overloading a function f() three times: The compiler provides prototypes and declarations for the 3 different versions
Correct only if the the overloads are generated by implicit instantiations of a function template
D) 2. but the programmer decides which one to use
Correct only if the template arguments are explicitly specified; other wise the compiler chooses the function by using the rules of overload resolution.
E) When overloading a function f() three times: The compiler decides which one to use depending on the return type.
I would say incorrect. Though if the overloads are generated by implicit instantiations of a function template with SFINAE being applied on the return type., this is subject to interpretation.