【c++】函数模板的简单应用

时间:2015-05-15 21:27:45   收藏:0   阅读:147
// 函数模板的简单应用

#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;
}



技术分享

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!