人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當(dāng)前位置:蘿卜系統(tǒng)下載站 > 技術(shù)開發(fā)教程 > 詳細(xì)頁(yè)面

DELPHI8設(shè)置符重載的例子

DELPHI8設(shè)置符重載的例子

更新時(shí)間:2022-09-02 文章作者:未知 信息來(lái)源:網(wǎng)絡(luò) 閱讀次數(shù):

unit WinForm;

interface

uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data;

type
  TWinForm = class(System.Windows.Forms.Form)
  {$REGION 'Designer Managed Code'}
  strict private
    /// <summary>
    /// Required designer variable.
    /// </summary>
    Components: System.ComponentModel.Container;
    Button1: System.Windows.Forms.Button;
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    procedure InitializeComponent;
    procedure Button1_Click(sender: System.Object; e: System.EventArgs);
  {$ENDREGION}
  strict protected
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    procedure Dispose(Disposing: Boolean); override;
  private
    { Private Declarations }
  public
    constructor Create;
  end;

  //寫成類也可以,這里我用了記錄。由于記錄是值類型省去了創(chuàng)建實(shí)例的麻煩
  TClassTest=record
  public
    FA:Integer;
    //重載了“+”操作符
    class operator add(A,B:TClassTest):TClassTest;
  end;

  [assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]

implementation

{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWinForm.InitializeComponent;
begin
  Self.Button1 := System.Windows.Forms.Button.Create;
  Self.SuspendLayout;
  //
  // Button1
  //
  Self.Button1.Location := System.Drawing.Point.Create(96, 88);
  Self.Button1.Name := 'Button1';
  Self.Button1.Size := System.Drawing.Size.Create(392, 112);
  Self.Button1.TabIndex := 0;
  Self.Button1.Text := 'Button1';
  Include(Self.Button1.Click, Self.Button1_Click);
  //
  // TWinForm
  //
  Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
  Self.ClientSize := System.Drawing.Size.Create(560, 357);
  Self.Controls.Add(Self.Button1);
  Self.Name := 'TWinForm';
  Self.Text := 'WinForm';
  Self.ResumeLayout(False);
end;
{$ENDREGION}

procedure TWinForm.Dispose(Disposing: Boolean);
begin
  if Disposing then
  begin
    if Components <> nil then
      Components.Dispose();
  end;
  inherited Dispose(Disposing);
end;

constructor TWinForm.Create;
begin
  inherited Create;
  //
  // Required for Windows Form Designer support
  //
  InitializeComponent;
  //
  // TODO: Add any constructor code after InitializeComponent call
  //
end;

procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs);
var
  A,B,C:TClassTest;
begin
  A.FA :=1;
  B.FA :=2;
  C:=A+B; //兩個(gè)結(jié)構(gòu)(或者類)用+操作,在DELHI8以前是不可想象的
  system.Windows.Forms.MessageBox.Show(System.Convert.ToString(C.FA) );
end;

{ TClassTest }

//重載“+”操作符的實(shí)現(xiàn)
class operator TClassTest.add(A, B: TClassTest): TClassTest;
begin
  Result.FA:=A.FA + B.FA;
end;

end.

溫馨提示:喜歡本站的話,請(qǐng)收藏一下本站!

本類教程下載

系統(tǒng)下載排行

網(wǎng)站地圖xml | 網(wǎng)站地圖html
主站蜘蛛池模板: 普安县| 土默特右旗| 拉萨市| 道真| 武隆县| 民乐县| 资溪县| 庆阳市| 田东县| 依兰县| 榕江县| 个旧市| 新安县| 博湖县| 凤庆县| 蓬溪县| 芜湖市| 鄂托克前旗| 修水县| 田林县| 深泽县| 仙居县| 南投市| 上高县| 大理市| 乌海市| 望江县| 年辖:市辖区| 海口市| 和政县| 石家庄市| 永仁县| 甘洛县| 巴青县| 衡东县| 雅江县| 确山县| 穆棱市| 大港区| 榕江县| 通辽市|