zoukankan      html  css  js  c++  java
  • Delphi out 参数 string Integer

    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 by reference, but it's assumed that the input value is irrelevant.

    out参数也是以引用传递,但是它(编译器)假定输入值是不相关的。

    For managed types, (strings, Interfaces, etc,) the compiler will enforce this, by clearing the variable before the routine begins, equivalent to writing param := nil.

    对(生存期自动)管理的类型(字符串,接口,等),编译器会强制在routine开始前清空out变量,等同于写参数值为空。

    For unmanaged types, the compiler implements out identically to var.

    对非管理类型,编译器实现out等同于var参数。

    Note that the clearing of a managed parameter is performed at the call-site and so the code generated for the function does not vary with out or var parameters.

    说明,对受管理类型参数的清理是在 调用位置 进行的,所以(编译器)为被调用函数产生的代码是不包括out或var参数的。

    share|edit

    edited Jan 24 '13 at 19:05

    David Heffernan
    316k22396683
    answered Jan 24 '13 at 17:38

    Mason Wheeler

    procedure testout(const str: string; out a: string; out I: Integer);
    begin
    ShowMessage(a + IntToStr(I));//100  a是空的
    a := str;
    I := 200;
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
    s, ss, ds, qx, dz: string;
    I: Integer;
    jo: ISuperObject;
    begin
    s := '外面';
    ss:= 'out';
    I:= 100;
    testout(s, ss, I);
    ShowMessage(ss + IntToStr(I));//外面200
    
    Exit;
    
    end;
    

      

  • 相关阅读:
    细说VMWare加入OpenStack
    云计算和大数据的崛起
    HTML5 Web app开发工具Kendo UI Web教程:如何配置Kendo UI Calendar
    Android:增强目录选择器对话框
    Gartner指明2014年几大战略技术趋势
    Android开发人员终于在“app-构建控制台”中获得分析
    谷歌升级Android分析应用程序
    Android是Windows开发人员可选择的下一个平台
    Greek
    为什么质数有无穷多个
  • 原文地址:https://www.cnblogs.com/CodeGear/p/4134679.html
Copyright © 2011-2022 走看看