c++期中考试题库.docVIP

  • 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

文档评论(0)

1亿VIP精品文档

相关文档