【c++】函式模板的簡單應用

zhaoyaqian552發表於2015-05-15
// 函式模板的簡單應用

#include <iostream>
using namespace std;

template<typename Type>
Type MAX(Type a, Type b)
{
	return a > b ? a : b;
}

int main()
{
	cout << MAX<float>(1.1,20) << endl;
	cout << MAX(10, 20) << endl;
	cout << MAX((float)2, (float)3) << endl;
	return 0;
}




相關文章