标签:c++ mamicode info ons return mic ace line 多个
#include <iostream>
using namespace std;
template <typename T>
inline T const& max(T const& a, T const& b)
{
return a < b ? b : a;
}
int main()
{
int i = 0;
int j = 3;
cout<<::max(i, j)<<endl;
double f1 = 3.4;
double f2 = -6.7;
cout << ::max(f1, f2) << endl;
string s1 = "as";
string s2 = "bs";
cout << ::max(s1, s2) << endl;
return 0;
}
#include <iostream>
using namespace std;
template <typename T1,typename T2>
inline T1 const& max(T1 const& a, T2 const& b)
{
return a < b ? b : a;
}
int main()
{
int i = 0;
double j = 3.9;
cout << ::max(i, j) << endl;
return 0;
}
#include <iostream>
using namespace std;
template <typename T1,typename T2,typename RT>
inline RT const& max(T1 const& a, T2 const& b)
{
return a < b ? b : a;
}
int main()
{
int i = 0;
double j = 3.9;
cout << ::max<int,double,double>(i, j) << endl;
return 0;
}
标签:c++ mamicode info ons return mic ace line 多个
原文地址:https://www.cnblogs.com/tailiang/p/11724852.html