64,642
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
using namespace std;
template<class T>
T max(T x,T y){return (x>y)?x:y;}
int main(){
int x = 10, y = 20;
float x1 = 10.3, y1 = 3.7;
double x2 = 12.99, y2 = 66.22;
cout<<"the max of x,y is:"<<max(x,y)<<"\n";
cout<<"the max of x,y is:"<<max<int>(x,y)<<"\n";
cout<<"the max of x1,y1 is:"<<max<float>(x1,y1)<<"\n";
cout<<"the max of x2,y2 is:"<<max<double>(x2,y2)<<"\n";
return 0;
}
int main(){
using namespace std;
……
}
2、比如只用cout就using std::cout