You can use placeholder parameters in conjunction with default parameters
Significance:
Leave clues for future expansion of the program
Possible nonstandard writing in compatible C language programs
C + + can declare placeholder parameters, which are generally used for program extensions and compatible int func for C code
(int A, int b, int = 0) {return
a + b;
}
void Main ()
{
//if the default and placeholder parameters are together, it can be invoked
func (1, 2);
Func (1, 2, 3);
System ("pause");
}
function Extension of the default parameter to C
1.c++ can provide a default value for a parameter when the function is declared.
When a function call does not specify a value for this parameter, the compiler automatically replaces the default value with the
void Myprint (int x = 3)
{
printf ("x:%d", x);
}
2. Rules for default parameters of functions
Only the parameters in the later part of the argument list can provide default parameter values. Once you start using the default parameter values in a function call, all parameters after this argument must use the default parameter values:
Default parameter
void printab (int x = 3)
{
printf ("x:%d\n", x);
}
In the default parameter rule, if the default parameter appears, then the right must have a default parameter
void printabc (int a, int b, int x = 3, int y=4, int z = 5)
{
printf ("x:%d\n" , x);
}
int main (int argc, char *argv[])
{
printab (2);
Printab ();
System ("pause");
return 0;
function extension of the default parameter to C
1.c++ can provide a default value for a parameter when the function is declared, and when the function is called without specifying the value of the parameter, the compiler automatically replaces the default value:
void Myprint (int x = 3)
{
printf ("x:%d", x);
}
2. Rules for default parameters of functions:
Only the parameters in the later part of the argument list can provide default parameter values.
Once you start using the default parameter values in a function call, all parameters after this argument must use the default parameter values.
Default parameter
void printab (int x = 3)
{
printf ("x:%d\n", x);
}
In the default parameter rule, if the default parameter appears, then the right must have a default parameter
void printabc (int a, int b, int x = 3, int y=4, int z = 5)
{
printf ("x:%d\n" , x);
}
int main (int argc, char *argv[])
{
printab (2);
Printab ();
System ("pause");
return 0;
}