函数的默认参数

函数占位参数

函数重载



总结:
函数的形参,有自己的参数值就用参数值,没有就用形参列表的默认值。
参数列表中,某位置有自己的默认值,从该位置起,往后就都必须设有默认值。
函数声明和函数实现,二者只能有一个设有默认值。
占位参数,就是在参数列表中,有一个自己的数据类型,该数据类型也可以有默认参数。
函数重载,特点:函数名可以相同,目的:提高复用性
函数重载的条件:
- 同一作用域下
- 函数名称相同
- 函数参数至少满足一个 函数参数类型不同,数量不同,顺序不同