Reputation: 27
Why am I getting an error saying:
in the following code:
template<typename T>
inline T const& max(T const& i, T const& j)
{
cout<<"Using template with 2 args."<<endl;
return (i>j) ? i : j;
}
template<typename T>
inline T const& max(T const& i, T const& j, T const& k)
{
cout<<"Using template with 3 args."<<endl;
return max(max(i,j),k);
}
void main()
{
cout<< ::max(1,2,3)<<endl;
}
I have already defined the 2 argument template function before calling it.
Upvotes: 0
Views: 71
Reputation: 55887
Remove using namespace std
, since there is std::max
, that takes part in search, thats why you get first error. Second error simply says, that there is unambiguous variant, but they should receive 3 args.
Upvotes: 2