• 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.

  • 相关阅读:
    Hbase安装与简单使用
    Integer Int
    Maven是什么
    对Servlet执行流程的初步认识
    android studio 开发环境的搭建
    centos下更换默认的python版本
    写出我心(七)
    写出我心(六)
    写出我心(五)
    写出我心(四)
  • 原文地址:https://www.cnblogs.com/studycode/p/10115754.html
Copyright © 2020-2023  润新知