If I have the following template methods:
template< typename T >
void function( T a )
{
cout<<"Template T"<<endl;
}
template< typename T >
void function( int a )
{
cout<<"Function taking Int"<<endl;
}
On calling function< float >( 2.5 )
, the second function gets called outputting: Function taking Int
.
If I try to instantiate the functions for the float type, I get
void function( float a );
And
void function( int a );
From which the first one seems to be the better match for the double type( arg 2.5 ) that I am passing.
Then, why does the program chooses the second method?