易截截图软件、单文件、免安装、纯绿色、仅160KB

Delphi 之运算符重载

Delphi 7之后的版本,增加了运算符的重载。虽然不尽人意(需要写特定英文),但有总比没有强。
例:
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
  T3DPoint = record
    X, Y, Z: Double;
    class operator ADD(ALeftPoint, ARightPoint: T3DPoint): T3DPoint; {重载'+'运算符}
  end;
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
{ T3DPoint }
class operator T3DPoint.ADD(ALeftPoint, ARightPoint: T3DPoint): T3DPoint;
begin
  Result.X := ALeftPoint.X + ARightPoint.X;
  Result.Y := ALeftPoint.Y + ARightPoint.Y;
  Result.Z := ALeftPoint.Z + ARightPoint.Z;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
  A, B, Z: T3DPoint;
begin
  A.X := 1; A.Y := 1; A.Z := 1;
  B.X := 3; B.Y := 3; B.Z := 3;
  Z := A + B;
  ShowMessageFmt('%f, %f, %f', [Z.X, Z.Y, Z.Z]); {4.00, 4.00, 4.00}
  //ShowMessage(FloatToStr(Z.X) + ',' + FloatToStr(Z.Y) + ',' + FloatToStr(Z.Z)); {4, 4, 4}
end;
end.
下面附上所有的运算符:
     重载特定英文                        行为(或目数)    方法                                                                   &nbs


相关文档:

Delphi字符串函数大全

Delphi字符串函数大全
uses StrUtils;
【字符串函数大全】
      首部 function AnsiResemblesText(const AText, AOther: string): Boolean;
      $[StrUtils.pas
      功能 返回两个字符串是否相似
      ......

delphi 编写的com 对象 用php调用的实例

delphi 编写的com 对象 用php调用

实例
delphi:
function Tmyxml.Get_xml: WideString;
begin
      Get_xml:='wo shi a lei!';
end;
function Tmyxml.Get_xmldata: WideString;
var
xmlStr:string;
begin
  xmlStr := '<?xml   version="1.0" & ......

我的Delphi开发经验谈

 
我的Delphi开发经验谈

作者:Icebird
--------
开发环境
--------
    Delphi
7是一个很经典的版本,在Win2000/XP下推荐安装Delphi 7来开发软件,在Vista下推荐使用Delphi 2007开发软件。安装好Delphi
7后,应立即安装Delphi 7 Update Pack 1,Delphi
2007则建议尽量安装最新 ......

Delphi in a Unicode World Part I

 ---
Delphi in a Unicode World Part I: What is Unicode, Why do you need
it, and How do you work with it in Delphi?
By: Nick
Hodges
原文链接:http://dn.codegear.com/article/38437
Abstract: This article discusses Unicode, how Delphi developers
can benefit from using Unicode, and ho ......

delphi字符串转换为char数组

var
  arrChar : array [0..4] of Char;
  b : Byte;
  s : string;
begin
  s := 'Test';
  Move(Pointer(s)^, arrChar, Length(s));   //string to array of char
  ShowMessage(arrChar);
  b := Ord(s[1]);   //First byte string to one single byte ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号