c++ (默认参数)

时间:2021-04-22 16:33:54   收藏:0   阅读:0

函数的默认参数

//注意事项:入股哦有一个位置有了默认参数,那么从这个位置开始,从左往后都必须有默认参数
//函数声明和实现里,只能有一个里面有默认参数,不能同时都有默认参数
void test03(int a = 20, int b = 30)
{cout << "a + b = " << a + b << endl;}
//占位参数,可以有默认值
//void test04(int a,int b=10){}
void test04(int a, int) {
}
int main()
{
	test03(5,5);
	return 0;
}
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!