• 深入方法(13)- 在 interface 区声明的方法


    //要点13: 需要给其他单元调用, 必须在 interface 声明, 但必须在 uses 区后面
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      end;
    
    {需要给其他单元调用, 必须在 interface 声明, 但必须在 uses 区后面}
    function MyFun(x,y: Integer): Integer; {函数声明}
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    function MyFun(x,y: Integer): Integer; {函数实现}
    begin
      Result := x + y;
    end;
    
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      i: Integer;
    begin
      i := MyFun(1,2);
      ShowMessage(IntToStr(i)); {3}
    end;
    
    end.
  • 相关阅读:
    堆排序
    伽马分布
    隔壁-贪心
    对刚—约瑟夫环
    站军姿-两圆并集
    单纯的线性筛素数
    3兔子
    2.圆桌游戏
    1.花
    历史
  • 原文地址:https://www.cnblogs.com/fansizhe/p/12729714.html
Copyright © 2020-2023  润新知