function template

/*
  function template
  programmer:qpz
*/
#include <iostream>
using namespace std;
template <class T>
class Myclass{
private:
	T x,y;
public:
	Myclass(T x,T y)
	{
		this->x=x;
		this->y=y;
	}
	T Max()
	{
		return x>y?x:y;
	}
};
int main(void)
{
//	Myclass s1(1,2.3); 错误申明
    Myclass <int> s1(1,2);
	cout<<s1.Max()<<endl;
	return 0;
}


posted @ 2014-12-15 20:56  机智的程序员小熊  阅读(145)  评论(0编辑  收藏  举报