1. If the default value is set for a certain parameter in the function, the default value must be set for all the parameters following the parameter.
2. You can set the default value when declaring a function. You can also set the default value when defining a function. However, you cannot set the default value at the same time.
3. If a function is used before the function is defined, and the default parameters are set during the function definition, and the default real parameters are also used during the call, an error occurs during compilation, during the compilation process, it is performed in the order before and after the file. When calling a function, you only see the declared function. When declaring the function, there is no default parameter. when calling the function, the real parameter is omitted and an error occurs, if you move the defined function to the call, no error will occur.
# Include <stdio. h> // int test (int a, int B = 10, int c = 20, int d = 30); int test (int a, int B, int c, int d); int main () {test (10); return 0;} int test (int a, int B = 10, int c = 20, int d = 30) // int test (int a, int B, int c, int d) {printf ("% d", a + B + c + d); return 0 ;}
This article is from "Li Haichuan" blog, please be sure to keep this source http://lihaichuan.blog.51cto.com/498079/1303998