DELPHI8操作符重载的例子

来源:计算机等级考试    发布时间:2012-08-29    计算机等级考试视频    评论

  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
  ///
  /// Required designer variable.
  ///

  Components: System.ComponentModel.Container;
  Button1: System.Windows.Forms.Button;
  ///
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  ///

  procedure InitializeComponent;
  procedure Button1_Click(sender: System.Object; e: System.EventArgs);
  {$ENDREGION}
  strict protected
  ///
  /// Clean up any resources being used.
  ///

  procedure Dispose(Disposing: Boolean); override;
  private
  { Private Declarations }
  public
  constructor Create;
  end;
  //写成类也可以,这里我用了记录。由于记录是值类型省去了创建实例的麻烦
  TClassTest=record
  public
  FA:Integer;
  //重载了“+”操作符
  class operator add(A,B:TClassTest):TClassTest;
  end;
  [assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]
  implementation
  {$REGION /'Windows Form Designer generated code/'}
  ///
  /// Required method for Designer support -- do not modify
  /// the contents of this method with the code editor.
  ///

  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
  //

上一页12下一页

视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答