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.

  • 相关阅读:
    js 报Unexpected token }
    c# 预览服务器文件
    js下载文件并修改文件名称
    js 自定义右键
    js 加载图片
    随笔1
    随笔
    php curl 发送post请求带参数
    laravel 数据库事务
    an't connect to local MySQL server through socket '/tmp/mysql.sock'
  • 原文地址:https://www.cnblogs.com/studycode/p/10115754.html
Copyright © 2011-2022 走看看