I also found that:
if using the following code
Code:
#include <iostream>
using namespace std;
template <class T,class T1> T addin(T a,T1 b)
{
return(a+b);
}
float addin(float a,int b)
{
// return(a+b);
cout<<"Using the reloaded function!\n";
}
int main(void)
{
int i=1;
float f1=10.5,f2=11.2;
cout<<addin(f1,i)<<endl;
cout<<addin(f1,f2)<<endl;
}
The output is :
Using the reloaded function!
-1.#IND
21.7
If using :
Code:
#include <iostream>
using namespace std;
template <class T,class T1> T addin(T a,T1 b)
{
return(a+b);
}
float addin(float a,int b)
{
return(a+b);
cout<<"Using the reloaded function!\n";//this line can't be shown
}
int main(void)
{
int i=1;
float f1=10.5,f2=11.2;
cout<<addin(f1,i)<<endl;
cout<<addin(f1,f2)<<endl;
}
The output is:
11.5
21.7
I feel strange about this. Can anyone help to explain them? Tks.