/*函数模板*/
#include <iostream>
using namespace std;

//template<typename T>   //也可以用typename关键字。
template<class T>
T mymax(T x, T y)
{
	return (x > y) ? x : y;
}

int main(void)
{
	cout << mymax(2.3f, 1.3f) << endl;
	cout << mymax(2, 3) << endl;
	cout << mymax('a', 'b') << endl;

	return 0;
}

相关文章:

  • 2021-05-04
  • 2021-12-06
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
猜你喜欢
  • 2022-12-23
  • 2021-06-29
  • 2021-04-10
  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
相关资源
相似解决方案