求助!!!有关输出语句的问题
#include<iostream>
using namespace std;
template<typename AA>
AA max1(AA x,AA y)
{ cout<<"调用模板函数:";
return (x>y)?x:y;
}
int max1(int x,int y)
{ cout<<"调用非模板函数:";
return (x>y)?x:y;
}
int main()
{
int i=12,j=32,as[4]={1,2,3,4},tt;
double d=234,w=445,ad[4]={5,6,7,8},ee;
char c='d',l='a';
cout<<"the max between int is:"<<max1(i,j)<<endl;
cout<<"the max between double is :"<<max1(d,w)<<endl;
cout<<"the max between char is:"<<max1(c,l)<<endl;
system("pause");
return 0;
}
这段程序没有问题。
运行结果是
调用非模板函数:the max between int is:32
调用模板函数:the max between double is :445
调用模板函数:the max between char is:d
求助:为什么结果不是
the max between int is:调用非模板函数:32
the max between double is :调用模板函数:445
the max between char is:调用模板函数:d