1.函数的默认参数:声明与实现只能有一个默认参数
#include<iostream>
using namespace std;
int func(int a,int b);
int func(int a=10,int b=20){
cout<<a+b<<endl;
return a+b;
}
int main(){
func();
return 0;
}
2.函数重载:
#include<iostream>
using namespace std;
void func(int a){
cout<<"func(int a)的调用!"<<endl;
}
void func(){
cout<<"func()的调用!"<<endl;
}
void func(int a,int b){
cout<<"func(int a,int b)的调用!"<<endl;
}
int main(){
func();
return 0;
}