http://www.delphibasics.co.uk/RTL.asp?Name=Out http://stackoverflow.com/questions/14507310/whats-the-difference-between-var-and-out-parameters A var parameter will be passed by reference, and that's it. var参数将以引用方式传递. An out parameter is also passed
(1)var修饰符 添加var 是地址传递,会修改原有的变量 var s: string; begin S := 'Hello'; ChangeSVar(s); ShowMessage(S); end; // ChangeSVar 定义 procedure TForm1.ChangeSVar(var A: string); begin A := A + 'World'; end; 以上会输出Hello World,因为是传址,修改的是原来的A (2)无任何修饰符 var s: string;
程序1 program E1; uses Forms,Dialogs,SysUtils, EndM1 in 'EndM1.pas' {Form2}; {$R *.res} begin Application.Initialize; Application.CreateForm(TForm2, Form2); then begin ShowMessage('缺少参数:'+Inttostr(ParamCount)); Application.Terminate; Exit; end; //在运行时去
Delphi的参数可以分为:默认参数(传值).var(传址).out(输出).const(常数)四类 可以对比C/C++的相关知识,类比学习. 1.默认参数是传值,不会被改变,例子 function MyFun(x : Integer) : Integer; begin Inc(x); Result := x; end; 2.var参数是传址,会被改变,例子 function MyFunVar(var x : Integer) : Integer; begin Inc(x); Result :=