Functions of the Out, Var and other key words of Delphi function, and the use of the scene

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.