zoukankan      html  css  js  c++  java
  • 深入方法(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.
  • 相关阅读:
    gems gems gems
    poj 6206 Apple
    lightoj1341唯一分解定理
    lightoj1370欧拉函数
    约瑟夫环lightoj1179
    拓展欧几里得算法
    RMQ算法
    poj1502MPI Maelstrom
    poj1860Currency Exchange
    生成全排列
  • 原文地址:https://www.cnblogs.com/fansizhe/p/12729714.html
Copyright © 2011-2022 走看看