Talking about the parameters of C ++ functions

xiaoxiao2021-03-06  54

The order of evaluation of the function parameters When a function is multiple parameters, the C language does not specify the order sequence of the actual parameters when the function call is called. The compiler is based on the need to optimize the code, specify the quotient order of the arguments. Some compilers are specified from left to right, and some compilers are specified from right to left. There is no impact on the general parameters of different regulations. However, if an operator with side effects in the actual parameters, it is possible to generate an erliness due to the order of evaluation. For example: int z = add_int ( x, x y); then, in different compilers, it is possible to produce different results. The default value of the setting parameters is in the C language, allowing one or more parameters to specify the default value when the function is explained or defined. However, the right side of the parameter specified by the default value cannot occur, and the parameters do not specify the default value cannot occur. For example: int Add_int (int X, INT 10); in the description of the function add_int (), a default value is specified on the rightmost parameter of the function. When the function is called, the compiler will participate in the combination of ginseng in the order from left to right. When the number of arguments is insufficient, the compiler will make up the default value in the same order in the description or defined by default. Arguments. For example, if the following function calls expression: add_int (15) it will call the expression with the following: add_int (15, 10) is equivalent. Specifying the default value to a parameter is not only a value, but also any complex expression. Using the array function parameter array as the function parameters can be divided into the following three cases: (the result of these three cases is the same, but the call mechanism used is different) 1. Converstrometry and the actual parameters are used. The array name, the array of modified functions, the mechanism for this call is the same array in the conformal parameters and the actual parameters. Therefore, in the modified function, a certain value in the array is changed, and the element value of the array of call functions is also changed because they are shared with the same array. 2. Conversion and arguments are used in C with corresponding arrays, and the array name is specified as a pointer, the pointer is a pointer to the first element of the array, and the country is the first element of the group. Address value, therefore, the array name is a constant pointer. In practice, the conformation and the inner parameters are used in the use of pointers, and the other is also possible. You can use an array name when using a pointer or a pointer to an array. 3. Reference Array NETET reference How to use the reference mode for array types, first do the following description: First use the type definition statement to define an INT type array type, as shown below: Typedef int Array [8]; then Using Array to define an array and reference. Example: #nclude typef int array [8]; int A [8] = {1, 3, 5, 7, 9, 11, 13}; void fun (array & b, int N) {for INT i = 0; I

转载请注明原文地址:https://www.9cbs.com/read-116560.html

New Post(0)