• 网络学院
  • IT资讯
  • 操作系统
  • 网络技术
  • 软件应用
  • 办公软件
  • 编程技术
  • 网站架设
  • 数据库类
  • 平面设计
  • 多媒体类
  • 游戏资讯
  • 教学论文
  • 认证考试
基础实例:DELPHI8操作符重载
  站点:
  • 首 页
  • 最新软件
  • 文章教程
  • 国内软件
  • 国外软件
  • 绿色软件
  • 源码下载
  • 字体下载
基础实例:DELPHI8操作符重载
软件发布 基础实例:DELPHI8操作符重载
网络软件 系统工具 应用软件 联络聊天 图形图像 多媒体类 行业软件 游戏娱乐 编程开发 安全相关 教育教学 数码软件 绿软下载
热门软件: QQ 瑞星 pplive e话通 木马克星 千千静听 office2000 五笔字根 Photoshop 视频分割
返回文章教程首页 >> 文章首页 >> 编程技术 >> Delphi教程 >> 基础实例:DELPHI8操作符重载

基础实例:DELPHI8操作符重载

添加时间: 2006-2-26 9:54:53  作者: Delphi教程  阅读次数:75   来源: http://www.d9soft.com

       

  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
  //
  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; //两个结构(或者类)用+操作,在DELHI8以前是不可想象的
  system.Windows.Forms.MessageBox.Show(System.Convert.ToString(C.FA) );
  end;

  { TClassTest }

  //重载“+”操作符的实现
  class operator TClassTest.add(A, B: TClassTest): TClassTest;
  begin
  Result.FA:=A.FA + B.FA;
  end;

  end.

 

 

上下文章:

 

上一篇文章: Delphi实现对注册表的监视和扫描 下一篇文章: 动态设置系统日期格式

相关文章:

  • 详解VLAN+路由器典型配置实例教程
  • ORACLE认证基础:ORACLE系统概述
  • oraclestatspack实例
  • 入门基础:连接常见错误及解决方法
  • 入门基础:认识OracleSQL内置函数

相关软件:

  • All AHM Triton Tools 2002 Borland Delphi V7.0
  • 佐尔表达式控件 For DELPHI 7.0 V3.1.12
  • Delphi Project Launcher V1.5
  • Delphi 5.0 完整汉化版
  • 轻松自考助学系列-法律基础与思想道德修养 1.30
  • CorelDraw12入门与实例

 

快速导航

  • 网络学院
  • 精品汇聚
  • 字体下载
  • 教程下载
  • ASP源码
  • PHP源码
  • Net源码
  • JSP 源码

编程技术分类导航

  • ASP & ASP.NET教程
  • PHP教程
  • JSP教程
  • C/C++教程
  • VB & VB.NET教程
  • VC教程
  • Delphi教程
  • BCB教程
  • VFP教程
  • PB教程
  • JAVA教程
  • XML教程
  • C#教程
  • CGI教程

本类经典文章推荐

  • Delphi的两个实用技巧(1)播放Flash
  • Delphi的两个实用技巧(2)巧用Wind...
  • delphi实例编程之--制作可随处拖放...
  • 关于VisiBroker For Delphi的使用...
  • 关于VisiBroker For Delphi的使用...
  • 关于VisiBroker For Delphi的使用...
  • 在线播放器DIY
  • Delphi让你发送Flash电子邮件
  • 在窗口标题区添加按钮
  • 用Delphi 6编程实现自动标注汉语拼...

Delphi教程阅读排行

  • Delphi7从入门到精通之历数Delphi...
  • Delphi的两个实用技巧(1)播放Flash
  • Delphi7从入门到精通之认识Delphi...
  • delphi实例编程之--制作可随处拖放...
  • Delphi控件,我们也可以(1)
  • Delphi的两个实用技巧(2)巧用Wind...
  • 在线播放器DIY
  • Delphi控件,我们也可以(2)
  • Spcomm串口控件的例程
  • 用Delphi + DirectX开发简单RPG游...

编程技术阅读总排行

  • VB入门教程之一
  • Java连接数据库实例
  • 第二章 PowerBuilder 入门之创建新...
  • VC++之List Box/Check List Box控...
  • 第一章 什么是PowerBuilder
  • VC++ List Ctrl控件
  • VC++ Combo Box/Combo Box Ex控件
  • 学C++不得不看的一篇文章
  • VB入门教程之二
  • VC++之Button控件

广告位置

字母检索 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 回到顶部

关于我们 | 版权声明 | 免责条款 | 广告联系 | 软件发布 | 下载帮助 | 下载排行 | 网站地图 | 特别鸣谢 | 友情连接

copyright; 2005-2008 D9soft.com 第九软件网 版权所有