⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 a_11_2.cpp

📁 C++应用教程原码,里面包含该书中有十三章内容的代码,详细具体
💻 CPP
字号:
#include "stdafx.h"
#include <iostream>
using namespace std;

template <class T>
T Max(T x, T y) { 
  cout<<"调用max(T x, T y),最大值为";
  return x > y ? x:y;
}
template <class U,int size>
U Max(U (&s)[size]) { 
  cout<<"调用max(U (&s)[size]),最大值为";
  U tempmax = s[0];
  for (int i = 0;i<size;i++)
	  if (tempmax < s[i])
		  tempmax = s[i];
  return tempmax;
}
void main() {
int x = 8, y = 23;
double a[5] ={ 2.342, 11.346, 8.93, 18.111,5.930};
cout << Max(x,y) << endl;
cout << Max(a);
cin.get(); //等待结束,以便调测程序,可以删除
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -