- 12
- 0
- 约4.21千字
- 约 6页
- 2015-09-25 发布于重庆
- 举报
c期中考试题库
1.声明一个类模板,利用它分别实现两个整数、浮点数和字符的比较,求出大数和小数。
#include iostream
template class num_temp
class Compare{
private:
num_temp x, y;
public:
Compare(num_temp a, num_temp b)
{
x = a;
y = b;
};
num_temp num_max()
{
return (x y) ? x : y;
};
num_temp num_min()
{
return (x y) ? x : y;
};
};
int main()
{
using namespace std;
Compareint cmp1(1, 9);
cout The Comparison of int (1 and 9) endl;
cout The max number : cmp1.num_max() endl;
cout The min number : cmp1.num_min() endl;
Comparefloat cmp2(1.99, 3.14);
cout The Comparison of float (1.99 and 3.14) endl;
cout The max nu
您可能关注的文档
- AOB格式分析 DVDAudio.doc
- An_Analysis_of_the_Differences_of_Family_Education_Between_China_and_America.doc
- Aogpeg常用法语日常用语.doc
- Apache PHP MySQL 的安装配置.doc
- Apache和Tomcat的整合方法.pdf
- Aperture Jitter Effects in Software Radio GNSS Receivers.pdf
- Appendix for “The Economic Value of Volatility Timing”.pdf
- APCERT亚太地区的应急合作经验 [杜跃进].pdf
- apache基于域名和端口的虚拟主机.doc
- API实现完美的图片出现效果.doc
原创力文档

文档评论(0)