zoukankan      html  css  js  c++  java
  • Delphi 接口统一方法

    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
    type
    IDemo=interface
    function A(i:Integer):Integer;
    end;
    
    type
    TDemo=class(TInterfacedObject,IDEmo)
    public
    function A(i:Integer):Integer;
    end;
    
    type
    TDemob=class(TInterfacedObject,IDEmo)
    public
    function A(i:Integer):Integer;
    end;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    { TDemo }
    
    function TDemo.A(i: Integer): Integer;
    begin
     ShowMessage('TDemo _'+inttostr(i));
    end;
    
    { TDemob }
    
    function TDemob.A(i: Integer): Integer;
    begin
     ShowMessage('TDemob _'+inttostr(i));
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
    Demob:TDemob;
    Demo:TDemo;
    vIDemo:IDemo;
    begin
     Demo:=TDemo.Create;
     Demob:=TDemob.Create;
    
    
     vIDemo:=IDemo(Demo);
     vIDemo.A(1);
    
    
     vIDemo:=IDemo(Demob);
     vIDemo.A(2);
    
    end;
    
    end.

  • 相关阅读:
    NGINX-HTTPS
    README
    SSH
    Ubuntu
    Python复利
    Python全双工聊天
    Python半双工聊天
    Python网络编程
    使用Python PIL库中的Image.thumbnail函数裁剪图片
    Python模块 os.walk
  • 原文地址:https://www.cnblogs.com/studycode/p/10115754.html
Copyright © 2011-2022 走看看