相关疑难解决方法(0)

使用数组重载运算符

我有这个单位:

unit Main.TIns;

interface

type
  TIns = record
  private type
    TInsArray = array [0..90] of Integer;
  var
    FInsArray: TInsArray;
  public
    class operator Implicit(const Value: Integer): TIns;
    class operator Add(const Elem1: TIns; const Elem2: Integer): TIns;
  end;

implementation

class operator TIns.Implicit(const Value: Integer): TIns;
var
  iIndex: Integer;
begin
  if Value = 0 then
    for iIndex := 0 to 90 do Result.FInsArray[iIndex] := 0;
end;

class operator TIns.Add(const Elem1: TIns; const Elem2: Integer): TIns;
begin
  Inc(Result.FInsArray[0]);
  Result.FInsArray[Result.FInsArray[0]] := Elem2;
end;

end.
Run Code Online (Sandbox Code Playgroud)

主要程序是: …

delphi delphi-xe2

3
推荐指数
1
解决办法
1559
查看次数

标签 统计

delphi ×1

delphi-xe2 ×1