0
点赞
收藏
分享

微信扫一扫

C++从入门到精通——模板


#include <iostream>
#include <exception>
using namespace std;

template <typename T>
T const& Max(T const& a,T const& b){

return a>b?a:b;

}
int main(){
int x,y;
float x1,y1;
string x2,y2;
x = 1;
y = 2;
x1 = 1;
y1 = 2;
x2 = "hello";
y2 = "world";

cout<<Max(x,y)<<endl;
cout<<Max(x1,y1)<<endl;
cout<<Max(x2,y2)<<endl;

}

C++从入门到精通——模板_c++


举报

相关推荐

0 条评论