Examlex

Solved

Which of the Following Template Function Definitions and Invocations Will

question 1

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 );
}


Definitions:

Free Trade

Global commerce conducted freely without the imposition of tariffs, quotas, or any limitations.

Leather Wallets

Small, flat cases made from leather, designed to hold personal items such as cash, credit cards, and identification documents.

Domestic Price

The price of goods or services within a country's domestic market, excluding international transactions.

Free Trade

An economic policy that allows imports and exports between countries with minimal governmental restrictions or tariffs to promote international trade.

Related Questions