C++-------默认参数

一、函数的默认参数必须放在参数位置的最后
如void show(int a,int b,int c=100);

    void show(int a,int b=100,int c=100);

1.主函数中调用函数时不使用默认参数:

int a,b,c;
a=10;
b=10;
c=10;
show(a,b,c); //此时调用show()函数时c的值是主函数的10而不是100

2.主函数中调用函数时使用默认参数:

a=10;
b=10;
c=10;
show(a,b); //此时调用show()函数时c的值是已有的参数值即100


二、占位参数
如void show(int,int) //不会报错,但是没有太多的实际意义,平常比较少用

原文地址:https://www.cnblogs.com/god-for-speed/p/10904834.html