gpt4 book ai didi

delphi - 记录初始化数组

转载 作者:行者123 更新时间:2023-12-03 15:44:27 26 4
gpt4 key购买 nike

我有这种类型:

type
TFieldRec = array of record
FieldName: string;
Value: Variant;
DataType: TFieldType;
Data: Pointer;
end;

代码:

var
FR: TFieldRec;
SetLength(FR, 5);

我的问题:是否保证每个记录元素都将使用默认值进行初始化?

'', Unassigned, ftUnknown, nil

在调试器中我可以看到这是真的。但我记得记录应该用 Initialize 初始化(或者是 Finalize?)

最佳答案

My question: is it guaranteed that each record element will be initialized with default values?

是的,这是有保证的。

SetLength documentation说(我的重点):

Existing elements in the array are preserved and newly allocated space is set to 0 or nil.

关于delphi - 记录初始化数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53479254/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com