例题4-6

来源:互联网 发布:知乎周刊到哪里看 编辑:程序博客网 时间:2024/06/05 17:35
#include <iostream>using namespace std;int main(){int max(int a,int b,int c);//参数个数不同的函数重载 int max(int a,int b); int a=8,b=-12,c=7; cout<<"max(a,b,c)="<<max(a,b,c)<<endl; cout<<"max(a,b)="<<max(a,b)<<endl; system("pause"); return 0;}int max(int a,int b,int c){if(b>a) a=b; if(c>a) a=c; return a;}int max(int a,int b){if(a>b) return a; else return b;}

原创粉丝点击