小编M.D*_*rov的帖子

无法为包含记录数组的对象赋值

我正在写一个包含记录数组的简单对象.就像发票一样.(ID,日期,客户名称和有关物品的记录数组).

type
  Trows = record
  private
    Fcode: string;
    Qty: Double;
    cena: Currency;
    procedure Setcode(const value: string);
  public
    property code: string read Fcode write SetCode;
  end;

  Tcart = class(TObject)
  private
    Frow: array of Trows;
    function  Getrow(Index: Integer): Trows;
    procedure Setrow(Index: Integer; const Value: Trows);
  public
    ID: integer;
    CustName: string;
    Suma: currency;
    Payed: boolean;
    constructor Create(const Num: Integer);
    destructor Destroy;
    function carttostr: string;
    procedure setcode(Index: integer;val: string);
    property Row[Index: Integer]: Trows read Getrow write setrow;
  end;
Run Code Online (Sandbox Code Playgroud)

一切似乎很好,因为我试图改变一条记录的价值.我找到了3种方法.首先,第二个工作正常,但我想简化修改此记录值的代码,如下所示:

cart.row[0].code:='333';
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

我错过了什么?

这是代码:

procedure …
Run Code Online (Sandbox Code Playgroud)

arrays delphi records assign

2
推荐指数
1
解决办法
320
查看次数

标签 统计

arrays ×1

assign ×1

delphi ×1

records ×1