类模板

#include <bits/stdc++.h>
using namespace std;
#define SPO(n) fixed << setprecision(n)
#define endl '\n'
#define ifor(i, l, r) for (long long(i) = (l); (i) <= (r); ++(i))
#define rfor(i, r, l) for (long long(i) = (r); (i) >= (l); --(i))
typedef long long ll;
const int IINF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1.0e-9;
const long long MOD = 1e9 + 7;
const long long MAX = 1e5 + 5;

template <class numtype>
class com {
		numtype c1;
		numtype c2;
	public:
		com(numtype x, numtype y);
		numtype max();
};
template <class numtype>
numtype com<numtype>::max() {
	return c1>c2?c1:c2;

}
template <class numtype>//类外定义构造函数,成员函数需要使用函数模板
com<numtype>::com(numtype x,numtype y) {
	c1=x;
	c2=y;
}
int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	com<int> a1(45,56);
	com<double>a2(56.230,461.2630);;
	cout<<a2.max();
	return 0;
}
全部评论

相关推荐

菜鸡29号:根据已有信息能初步得出以下几点: 1、硕士排了大本和大专 2、要求会多语言要么是招人很挑剔要么就是干的活杂 3、给出校招薪资范围过于巨大,说明里面的薪资制度(包括涨薪)可能有大坑
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务