Delphi parameters can be divided into: default parameters (Value), VAR (address), out (output), const (constant) four class
You can compare the knowledge of C + + with analogy learning.
1. The default parameter is the pass value, will not be changed, example
function Myfun (x:integer): Integer;begin Inc (x); Result: = X;end;
The 2.var parameter is the address that will be changed, example
function Myfunvar (var x:integer): Integer;begin Inc (x); Result: = X;end;
3.out parameters are supported for COM, and the result of Var is the same, generally we do not need
function myfunout (out X:integer): Integer;begin Inc (x); Result: = X;end;
4.const parameters are absolutely not assignable, this is the way the compiler optimizes, as much as possible
function Myfunconst (const X:integer): Integer;begin Inc (x); This is an error because the parameter with the const prefix is the Result that cannot be modified : = X;end;
Here are the tests that call these functions
Procedure Tform1.button1click (sender:tobject); var a:integer;begin A: = 5; Myfun (a); ShowMessage (IntToStr (a)); 6 A: = 6; Myfunvar (a); ShowMessage (IntToStr (a)); 7 A: = 6; Myfunout (a); ShowMessage (IntToStr (a)); 7 A: = 6; Myfunconst (a); ShowMessage (IntToStr (a)); 6, because in the myfunconst is not the const parameter can be modified end;
Delphi function Parameters Pass default parameters (value values), VAR (pass-through), out (output), const (constant) class four