Help!!,I'm learning C++ function template,but
What's wrong with the prog.
#include<iostream>
using namespace std;
template<typename t> t min1(t a,t b){return a>b?b:a;}
int main()
{
cout << min1(3.0,4.0)<<endl;
cout << min1<double,double>(7,8)<<endl; //Error :no matching function for call to 'min<int,int>'
//Why do not support Explicit Template Arguments;
return 1;
}
tom
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Help!!,I'm learning C++ function template,but
What's wrong with the prog.
#include<iostream>
using namespace std;
template<typename t> t min1(t a,t b){return a>b?b:a;}
int main()
{
cout << min1(3.0,4.0)<<endl;
cout << min1<double,double>(7,8)<<endl; //Error :no matching function for call to 'min<int,int>'
//Why do not support Explicit Template Arguments;
return 1;
}
tom
error line shoud be: cout <<min1<double>(7,8)<<endl;