程序哪里改一下额可以实现目的

#include <iostream>                                 // 预处理命令                                     //2

using namespace std;                                // 使用标准命名空间std                      //3

                                                                                                                   //4

template <class ElemType>                                                                                //5

ElemType Max(ElemType a, ElemType b)     // 返回最大值                                     //6

{                                                                                                                 //7

   return (a > b) ? a : b;                       // 返回ab的最大值                         //8

}                                                                                                                 //9

                                                                                                                   //11

int main(void)                                            // 主函数main(void)                          //12

{                                                                                                                 //13

   cout << Max(16, 518) << endl;              // 显示最大值                                     //14

   cout << Max(16.8, 518) << endl;    // 显示最大值                                     //15

                                                                                                                   //16

   system("PAUSE");              // 调用库函数system( ), 输出系统提示信息                //17

       return 0;


breeze0
浏览 1229回答 1
1回答

asd8532

cout << Max<int>(16, 518) << endl;              // 函数模板要加<>,里面要填上类型才可以的                               cout << Max<double>(16.8, 518) << endl;
打开App,查看更多内容
随时随地看视频慕课网APP