Parameter passing problems, methods of parameter passing

Updated on technology 2024-02-09
9 answers
  1. Anonymous users2024-02-05

    Use the byval keyword to indicate that the parameter is passed by value, but your first argument is written by byref, which is passed by address, and the second argument is written at nothing, and it is also passed by address by default.

  2. Anonymous users2024-02-04

    b as integer should be preceded by a byval because the previous arguments are passed by value, and if the following arguments are not written, they are still passed by address by default, so they must all be explained.

    PS: Because a and b are both form parameters of i.

  3. Anonymous users2024-02-03

    There are two ways to do this: Value Type and Reference TypeWhen assigning data to a value type and a reference type, the two behave completely differently: When assigning data to a value type, the data is stored in variables on the stack.

    When assigning data to a reference type, only one reference is stored in the variable, and the data is stored on the managed heap. It is very important to understand the difference between a stack and a heap. A stack is a relatively small area of memory where processes and threads store fixed-sized blocks of data.

    For example, the number of bytes required to store integers and decimal types does not change, regardless of the actual value of the data. So the position of such a variable in the stack can be determined efficiently (when a process needs to extract a variable, the stack must be searched. If the stack contains variables with dynamic memory sizes, this search takes a long time).

    There is no fixed size for reference types. For example, the size of a string can vary from 2 bytes to close to all available memory in the system. The uncertainty of reference type macros means that the data they contain is better suited to be stored on the heap rather than the stack, however, the address of the reference type (i.e., the location of the data on the heap) has a fixed size and can therefore be stored on the stack.

    By storing references on the stack, the whole program will run much faster because the process can quickly locate the data in the variables. Fixed-size variables and dynamically sized variables are stored on the stack and on the heap, respectively, which can make the two variables work differently. This is illustrated below by comparing the struct (a value type) and the StringBuilder class (a reference type).

    The point structure is. .NET Graphics Library, which is part of the namespace. The StringBuilder class is part of the namespace and is used to efficiently string strings.

    Namespaces are discussed in Chapter 8.

  4. Anonymous users2024-02-02

    Pass parameters by value.

    If the value of the parameter is changed during the call, the parameter variable itself will not be affected, that is, the value of the parameter variable remains unchanged before the call. If you want to pass a parameter by value, you must add the byval keyword to the parameter name.

    Pass parameters by address.

    When passing a parameter by address, the address of the argument variable is passed to the same address in the memory shared by the called procedure, and the argument and the argument share the same address. In the process of being called, once the value of the parameter changes, the value of the corresponding argument also changes. If the argument is a constant or expression, Visual Basic will handle it as a value, and the byval keyword is not required for passing it by address.

    Pass parameters in arrays.

    In , it is allowed to use an array as an argument to pass the parameters of the subprocedure, and the array pass must be done by way of address passing. There are two aspects that should be paid attention to when passing array parameters:

    When the array is passed as a parameter, the system passes the starting address of the real parameter group to the process, so that the shape parameter group also has the same starting address as the real parameter group, if the parameter is a multi-dimensional array, each dimension is separated by a comma;

    The modulated process can determine the lower and upper bounds of the real parameter group through the lbound and ubound functions, respectively.

  5. Anonymous users2024-02-01

    The transfer here of course refers to how the arguments are passed to the parameters.

    It's quite complicated bKhan, and here is a description of the situation and precautions for the transfer of 4 parameters:

    1.Non-referential parameters.

    This is the most common and simplest form parameter transfer.

    Parameter passing, that is, using a copy of the argument (note that it is a copy, not the argument itself) to initialize the parameter;

    Therefore, the modification of the parameters in the function body does not affect the value of the arguments.

    If the parameter is of the pointer type, is it possible to change the value of the object that the pointer points to in the function body?

    If you have such doubts, it means that you have a lot of ideas

    The answer is that it needs to be discussed on a case-by-case basis.

    If the parameter of a function is a pointer of a non-consult type, the function can use the pointer to assign a value to modify the value of the object pointed to by the pointer.

    So, if you want to protect the value that the pointer points to, the parameter needs to be defined as a pointer to a st object (note that the pointer here is still non-const, but the object it points to is const).

    void use_ptr(const int *p)

    const parameters.

    If the function uses a non-referenced, non-const parameter, you can pass either a st argument or a non-const argument to it.

    If the function uses a non-referential const parameter, it can pass both a and a non-const argument to it. So what's the difference between the two? In the case of the latter, the function cannot even be changed by a partial copy of the arguments.

    Here's an example of the second case: void fcn(const int i).

    void printvalues(int[10]) if int j[2]= is defined, when the function is called, printvalues(j,j+2)

    3.Explicitly pass a parameter that represents the size of the array. void printvalues(const int ia, size_t size){}

    5.Deformable parameters.

    The ellipsis in C++ is used to compile C programs that use varargs.

    void foo(parm_list,..

    void foo(..

  6. Anonymous users2024-01-31

    It is to transfer the variables on Earth to Mars, but Mars cannot be transmitted back unless a pointer is used.

  7. Anonymous users2024-01-30

    It is the input independent variable and the output dependent variable. Are you talking about programming?

  8. Anonymous users2024-01-29

    Value passing: (the formal parameter type is the basic data type): when the method is called, the actual parameter passes its value to the corresponding formal parameter, and the formal parameter only initializes its own storage unit content with the value of the actual parameter, which is two different storage units, so the change of the formal parameter value in the method execution does not affect the value of the actual parameter.

    When the argument method is called, the actual argument is an object (or array), then the actual argument and the formal argument point to the same address, in the method execution, the operation on the formal argument is actually the operation on the actual parameter, and this result is retained after the end of the method, so the change of the formal argument in the method execution will affect the actual parameter.

  9. Anonymous users2024-01-28

    Parameters: Indicates the names of variables and arrays in the table of parameters of the sub and function procedures, which are not allocated memory before they are called, and their role is to explain the type and form of the independent variables and their role in the process. Arguments can be valid variable names other than fixed-length string variables, or array names with parentheses.

    Arguments: Arguments are the parameter values that are passed from the main procedure to the called procedure when the sub and function procedures are called. Arguments can be variable names, array names, constants, or expressions.

    When passing parameters in a procedure call, the parameters are combined according to position, and the names of the variables in the parameter table and the parameter table do not have to be the same, but their data types, parameter numbers, and positions must correspond to each other.

    Relationship between the two:1Parameters can only be variables, and arguments can be constants, variables, or expressions. In the defined function, the type of parameter must be specified.

    2.The number of actual participating parameters should be the same, and the types should be the same. Character and integer types can be used in common with each other.

    3.When calling a function, if the argument is the name of the array, the first address of the array is passed to the argument.

    4.The arguments are passed to the parameters in one direction, and the parameter variables do not occupy memory when the function is not called, but only when the function is called. When the call ends, the memory is freed.

    When executing a called function, if the value of the parameter is changed, it will not change the value of the argument in the key function.

    5.The form parameter is like the symbol in the formula, and the real parameter is the specific value of the symbol, which must be assigned before the process is called. The invocation process is to realize the combination of the form and the real argument, and pass the value of the real argument to the form argument through the call, which is equivalent to substituting the value into the formula for calculation.

Related questions
11 answers2024-02-09

To be clear, only"Value parameters and variable parameters"How can I help you?

5 answers2024-02-09

Mainly letters. Passed through the post station.

8 answers2024-02-09

2D array address - > row address - > column address (variable address) - > variable value, or excerpt a description for you. >>>More

7 answers2024-02-09

The world is full of color, as long as everyone gives a little love, the world will become a better worldToday, I watched a public service announcement. The content of the advertisement reads: The start screen is gray, and at this point, a woman with a child comes up. >>>More

6 answers2024-02-09

Part M: 12 part number.

lot number. >>>More