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.

Computer Science & Information Technology

You might also like to view...

Which of the following will occur when a switch encounters an unknown destination unicast frame?

A) The switch will flood the frame. B) The switch will determine if the incoming frame has a known source. C) The switch will filter the frame. D) The switch will add the destination to its address table.

Computer Science & Information Technology

A Facebook ____________________ page contains a user's personal information.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

With Google Forms, as users complete the form, each response is automatically appended as a new ____________________ in the Google spreadsheet, along with a timestamp that shows when the response was received.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

The word shown in bold is used correctly in the following sentence.Who'sidea was it to have a meeting??

Answer the following statement true (T) or false (F)

Computer Science & Information Technology