⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdelphinetrecordprocs.out

📁 格式化源码的最新板
💻 OUT
字号:
unit TestDelphiNetRecordProcs;

interface

type
  TSomeRecord = record
    i, j, k, l: integer;

    function Sum: integer;
    procedure Clear;

    constructor Create(iValue: integer);
  end;

  // a record with operator overloads
  TOpRecord = record
    i: integer;
    s: string;
    class operator Add(A, B: TOpRecord): TOpRecord;
    class operator Equal(A, B: TOpRecord): boolean;
    class operator Implicit(A: TOpRecord): integer;
    class operator Implicit(A: integer): TOpRecord;
  end;

  TPropertyRecord = record
  private
    fi, fj: integer;

    function GetTwiceI: integer;
    function GetTwiceJ: integer;
    procedure SetTWiceI(const Value: integer);

  public
    property I: integer Read fi Write fi;

    property TwiceI: integer Read GetTwiceI Write SetTWiceI;
    property TwiceJ: integer Read GetTwiceJ;

  end;

implementation


{ TSomeRecord }

procedure TSomeRecord.Clear;
begin
  i := 0;
  j := 0;
  k := 0;
  l := 0;
end;

constructor TSomeRecord.Create(iValue: integer);
begin
  Clear;
  i := iValue;
end;

function TSomeRecord.Sum: integer;
begin
  Result := i + j + k + l;
end;

{ TOpRecord }

class operator TOpRecord.Add(A, B: TOpRecord): TOpRecord;
begin
  Result.i := A.i + B.i;
  Result.s := a.s + b.s;
end;

class operator TOpRecord.Equal(A, B: TOpRecord): boolean;
begin
  Result := (a.i = b.i) and (a.s = b.s);
end;

class operator TOpRecord.Implicit(A: integer): TOpRecord;
begin
  Result.i := A;
  Result.s := '';
end;

class operator TOpRecord.Implicit(A: TOpRecord): integer;
begin
  Result := A.i;
end;

{ TPropertyRecord }

function TPropertyRecord.GetTwiceI: integer;
begin
  Result := fi * 2;
end;

function TPropertyRecord.GetTwiceJ: integer;
begin
  Result := fj * 2;
end;

procedure TPropertyRecord.SetTWiceI(const Value: integer);
begin
  fi := Value div 2;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -