我正在开发类来表示特殊类型的矩阵:
type
DifRecord = record
Field: String;
Number: Byte;
Value: smallint;
end;
type
TData = array of array of MainModule.DataRecord;
type
TDifference = array of DifRecord;
type
TFogelMatrix = class
private
M: Byte;
N: Byte;
Data: ^TData;
DifVector: ^TDifference;
procedure init();
public
constructor Create(Rows, Cols: Byte);
destructor Destroy;
end;
现在在构造函数中,我需要为 Data 和 DifVector 类成员保留内存。如您所见,我使用指向记录数组的指针。所以,主要问题是,我怎样才能正确地保留内存?我想我不能使用这样的东西:
因为我正在失去主要想法 - 在运行时尽可能多地保留内存空间。感谢您的评论。
new(Data);
new(DifVector);