Examveda

What will be the output of the following C++ code?
#include <iostream>
using namespace std; 
template <class T>
T max (T &a, T &b)
{
	cout << "Template Called ";
    return (a > b)? a : b;
}
 
template <>
int max <int> (int &a, int &b)
{
    cout << "Called ";
    return (a > b)? a : b;
}
 
int main ()
{
    int a = 10, b = 20;
    cout << max <int> (a, b);
}

A. Template Called 20

B. Called 20

C. Error

D. Segmentation fault

Answer: Option B


Join The Discussion

Related Questions on C plus plus miscellaneous

What is the difference between '++i' and 'i++' in C++?

A. None of the above

B. They both have the same effect

C. '++i' increments the value of 'i' before returning it, while 'i++' increments the value of 'i' after returning it

D. '++i' increments the value of 'i' after returning it, while 'i++' increments the value of 'i' before returning it