ITeye博客

type template

speed847 · 2013-10-23 10:52 · Code Repository C++ · Web前端 · Markdown

#include <iostream>
using namespace std;

template <typename T>
T max(T a, T b, T c){
	if(b>a)a=b;
	if(c>a)a=c;
	return a;
}

int mainTT() {
	int i1=185, i2=-76, i3=567,i;
	double d1=56.78, d2=90.23, d3=-4321.4,d;
	long g1=6789, g2=-9876, g3=234567,g;

	cout << max(i1,i2,i3) << endl;
	cout << max(d1,d2,d3) << endl;
	cout << max(g1,g2,g3) << endl;

	system("pause");
	return 0;
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。