相关疑难解决方法(0)

请求如何使用TComplexMath类的简单示例(包含源代码)

我正在使用Borland Delphi7进行一些Pascal编程.我已经下载了一个相当基本(和免费)的复杂数学函数源代码库,但不幸的是它没有附带任何用法示例.由于我对Pascal中的类不太熟悉,我想我只需要一个简单的例子就可以让我开始使用它.

任何事都会做,即使是将两个数字加在一起的例子也会让我开始.这是我尝试过的(非常蹩脚,我知道).我认为我的问题是我不知道如何使用类构造函数.

uses ComplexMath in 'complexmath.pas'

var z1,z2,z3 : TComplexNumber;
begin
  z1.R:=1.0; z1.I:=2.0;
  z2.R:=3.0; z2.I:=-1.0;
  z3 := TComplexMath.Add(z1,z2);
end.
Run Code Online (Sandbox Code Playgroud)

有关TComplexMath的完整源代码,请访问:http://delphi.about.com/library/weekly/aa070103a.htm .我还剪切并粘贴了下面的源代码的部分列表(请注意,此代码是完整的文件,除了我明确表示已被剪切的地方).

部分TComplexMath源代码列表是:

unit ComplexMath;

interface

uses Windows, SysUtils, Classes, Controls, Math;

type
  TComplexNumber = record
    R : single;
    I : single;
  end;

TComplexMath = class(TComponent)
  private
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(AOwner : TComponent); override;

    function Add(C1, C2 : TComplexNumber) : TComplexNumber; overload;
    { Returns the complex …
Run Code Online (Sandbox Code Playgroud)

delphi

3
推荐指数
2
解决办法
705
查看次数

标签 统计

delphi ×1