Which of the following template function definitions and invocations will not compile, if any? If not, why not?
Assume that classes have been declared with appropriate default constructors and
assume that
```
//a)
template
A func( A x, A y){ return A(); }
int main()
{
U u1, u2, u3;
u2 = func(u2, u3);
}
//b.
template
B func() { return 1; }
int main()
{
T t;
t = func();
}
//c.
template
void func(C x, int * y){}
int main()
{
T t;
int i;
func( t, &i );
}
//d.
template
void func(D x, E y){}
int main()
{
T t;
U u;
func ( t, u );
}
```
The answers are somewhat compiler dependent. The only failure that my
compilers detect is in compiling part b. The failure is due to a violation of the
requirement that each template type argument be used in the function argument list. The template facility cannot determine the type of the template from the return type alone.
You might also like to view...
Pressing Enter three times at the end of a multiple-items form will open ________
A) a table of underlying data B) a query of underlying data C) form editor D) a single-record form
If the default automatic approval rule is enabled, what types of updates are approved automatically?
What will be an ideal response?