第12题
来源:互联网 发布:淘宝1元秒杀 编辑:程序博客网 时间:2024/05/16 07:09
#include <iostream>
using namespace std;
template<class numtype>
class Compare
{
public:
Compare(numtype a,numtype b);
numtype max();
numtype min();
private:
numtype x,y;
};
template<class numtype>
Compare<numtype>::Compare(numtype a,numtype b)
{
x=a;
y=b;
}
template<class numtype>
numtype Compare<numtype>::max()
{
return (x>y)?x:y;
}
template<class numtype>
numtype Compare<numtype>::min()
{
return (x<y)?x:y;
}
int main()
{
Compare<int> cmp1(3,7);
cout<<cmp1.max()<<"is the Maximum of two integer numbers."<<endl;
cout<<cmp1.min()<<"is the Minimum of two integer numbers."<<endl;
Compare<float> cmp2(45.78,93.6);
cout<<cmp2.max()<<"is the Maximum of two integer numbers."<<endl;
cout<<cmp2.min()<<"is the Minimum of two integer numbers."<<endl;
Compare<char> cmp3('a','A');
cout<<cmp3.max()<<"is the Maximum of two characters."<<endl;
cout<<cmp3.min()<<"is the Minimum of two characters."<<endl;
}
- 第1章 第12题
- 第3章 第12题
- P51 第12题
- 第一章第12题
- P51第12题
- P51第12题
- p51 第12题
- 第12题
- 第12题
- 第12题
- 第12题
- 第12题
- c++第12题
- 第12题
- lintcode 第12题
- 第12周“知原理”第5题
- 第12章课后第5题答案
- leetcode 第11-12题
- 【转自mos文章】在linux 下正确分辨用的是哪种cpu
- 友情提醒:欲开发android5.0以上应用,请全部更新开发工具至最新
- 第四章第7题
- c++操作txt
- 4.27NDK相关
- 第12题
- 关于使用facebook的Android调试工具Stetho时遇到的问题
- Android“上拉刷新/下拉加载”与“侧滑菜单”的兼容
- 第11讲-项目四-双精度浮点数的和、平均值、平方和以及平方和开根号
- 一年博客有感
- Android Studio--系列教程
- POJ3553 Task schedule (拓扑排序+优先队列)经典
- 反转字符串
- 第一题