S
Sooraj S
H, I am new to templates. Can anyone tell me why the program gives me
the error?
template <class T> T min(T a, T b)
{
if (a < b) { cout << a << "is minimum"; }
else { cout << b << "is minimum"; }
return (a<b) ? a:b;
}
int main()
{
min <int> (10,12);
}
OUTPUT:
In function 'int main()':
Line 9: error: call of overloaded 'min(int, int)' is ambiguous
compilation terminated due to -Wfatal-errors.
the error?
template <class T> T min(T a, T b)
{
if (a < b) { cout << a << "is minimum"; }
else { cout << b << "is minimum"; }
return (a<b) ? a:b;
}
int main()
{
min <int> (10,12);
}
OUTPUT:
In function 'int main()':
Line 9: error: call of overloaded 'min(int, int)' is ambiguous
compilation terminated due to -Wfatal-errors.