Problem description
-
Functions of the Out, Var and other key words of Delphi function, and the use of the scene
-
Delphi functions out, Var and other key words, and the use of the scene, I know that Var is called as a value call, but like out of the key word is what role?
Solution Solutions
In a procedure or function, out is primarily used for COM and CORBA Technologies, Delphi explains:
An out parameter, like a variable parameter, is passed by reference. With an out parameter, however, the initial value of the referenced variable is discarded by the routine it is passed to. The out parameter is for output only; that is, it tells the function or procedure where to store output, but doesn‘t provide any input.
The point is, "it's only useful to let the programmer of the writing process remind you that this parameter has no initial value and can only be assigned to it, never to use its value." ”
1, the same: Var and out modified parameters, are guided by pointers to the parameters of the variables, they can be out of the output value;
2. Difference: var modifier parameter, can bring in value and use in procedure or function; out modifier parameter, with invalid value. The actual arguments passed out to the procedure do not have to be initialized.
In a procedure or function, out is primarily used for COM and CORBA Technologies, Delphi explains:
An out parameter, like a variable parameter, is passed by reference. With an out parameter, however, the initial value of the referenced variable is discarded by the routine it is passed to. The out parameter is for output only; that is, it tells the function or procedure where to store output, but doesn‘t provide any input.
The point is, "it's only useful to let the programmer of the writing process remind you that this parameter has no initial value and can only be assigned to it, never to use its value." ”
1, the same: Var and out modified parameters, are guided by pointers to the parameters of the variables, they can be out of the output value;
2. Difference: var modifier parameter, can bring in value and use in procedure or function; out modifier parameter, with invalid value. The actual arguments passed out to the procedure do not have to be initialized.
Solution Two:
Out is the outgoing value, a function has only one return value, and you can use out to treat the parameter as a return value. Unlike Var, var must be initialized before it is called, and out is not required.
Solution Three:
Out is sent only to the outside, VAR can be returned, can also be passed in. Seems to be the difference.
Source: https://yq.aliyun.com/wenzhang/show_40884
Functions of the Out, Var and other key words of Delphi function, and the use of the scene