Solved

Which of the Following Template Function Definitions and Invocations Will

Question 25

Essay

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<class A>
A func( A x,A y){ return A();}
int main()
{
U u1,u2,u3;
u2 = func(u2,u3);
}
//b.
template<class B>
B func(){ return 1;}
int main()
{
T t;
t = func();
}
//c.
template<class C>
void func(C x,int * y){}
int main()
{
T t;
int i;
func( t,&i );
}
//d.
template<class D,class E>
void func(D x,E y){}
int main()
{
T t;
U u;
func ( t,u );
}

Correct Answer:

verifed

Verified

The answers are somewhat compiler depend...

View Answer

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents