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...
You can use the Word mail merge feature to send custom e-mail messages
Indicate whether the statement is true or false
The Clipboard is a permanent storage area
Indicate whether the statement is true or false