重载问题

来源:百度知道 编辑:UC知道 时间:2024/09/23 01:23:09
函数int test(int a,int b=1,int c=0)

下列调用哪个不合法,为什么
test(0), test(0,0), test(), test(0,0,0);

test函数有三个参数,全部是int型
因为后2个参数有默认值,而第一个参数没有,所以函数调用时可以给一个,两个或者三个参数,所以test()调用不合法。

test()

只有a没有默认值,所以至少要对a进行参数传递