#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