码迷,mamicode.com
首页 > 其他好文 > 详细

函数的重载

时间:2017-11-10 00:19:14      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:log   技术分享   std   lin   images   mes   using   end   space   

#include <iostream>
using namespace std;

int max(int x ,int y,int z);
double max(double x ,double y,double z);
long max(long x ,long y,long z);

int main(){
    
    int a,b,c,m;
    cout<<"请你输入三个整型的数字:"<<endl;
    cin>>a>>b>>c;
    m=max(a,b,c);
    cout<<"The max of a b and c is:"<<m<<endl;
    
    double ad,bd,cd,md;
    cout<<"请你输入三个小数类型的数字:"<<endl;
    cin>>ad>>bd>>cd;
    md=max(ad,bd,cd);
    cout<<"The max of a b and c is:"<<md<<endl;
    
    long al,bl,cl,ml;
    cout<<"请你输入三个长整型的数字:"<<endl;
    cin>>al>>bl>>cl;
    ml=max(al,bl,cl);
    cout<<"The max of a b and c is:"<<ml<<endl;
    return 0;
} 
inline int max(int x ,int y,int z){
    if(z>x)
    x=z;
    if(y>x)
    x=y;
    return x;
}
inline double max(double x ,double y,double z){
    if(z>x)
    x=z;
    if(y>x)
    x=y;
    return x;
}
inline long max(long x ,long y,long z){
    if(z>x)
    x=z;
    if(y>x)
    x=y;
    return x;
}

技术分享

函数的重载

标签:log   技术分享   std   lin   images   mes   using   end   space   

原文地址:http://www.cnblogs.com/928990166li/p/7811600.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!