首页 > 其他 > 详细

函数重载条件有三条

时间:2020-03-18 14:33:34      阅读:192      评论:0      收藏:0      [点我收藏+]
#include<iostream>
//函数占位参数如下
    // void se(int)-
//函数重载,允许函数名重复,但是参数数量不同
//函数重载条件
    //1.同一个作用下
    //2.函数名相同
    //3.函数参数类型不同,或者参数个数或顺序不一样。 
    //函数返回值不可以作为函数重载的条件 
using namespace std;
int func(int a, int b)
{
    return a+b;
} 
int func(int a, int b,int c)
{
    return a+b+c;
} 
//因为函数参数个数不用而进行的函数重载
int  
int main()
{
    cout << func(5,6) << endl;
    cout << func(5,6,7) << endl;
    system("pause");
    return 0; 
} 

 

函数重载条件有三条

原文:https://www.cnblogs.com/gjbhpu0308/p/12517219.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!