gpt4 book ai didi

delphi - 相互依赖的程序变量和记录

转载 作者:行者123 更新时间:2023-12-03 15:45:04 25 4
gpt4 key购买 nike

我有以下构造:

program Project26;

{$APPTYPE CONSOLE}
{$R *.res}
type

TPrint_address_func = function(offset: integer; info: disassembler_info): boolean;

disassembler_info = record
data: string;
print_address_func: TPrint_address_func;
end;

begin
end.

显然,函数类型的记录需要在前向声明中声明。
I know that I cannot declare the record as forward ,但是……

有没有办法将过程变量声明为转发?
或者我可以用老式对象替换该记录并将声明为转发吗?

最佳答案

您不能转发声明过程类型或记录。因此,结论是您必须将类型定义放在记录中:

type
disassembler_info = record
type
TPrint_address_func = function(info: disassembler_info): boolean;
var
data: string;
print_address_func: TPrint_address_func;
end;

FWIW,一旦我开始在记录中定义类型,我倾向于开始使用可见性说明符来分解声明。我会这样声明这个类型:

type
disassembler_info = record
public
type
TPrint_address_func = function(info: disassembler_info): boolean;
public
data: string;
print_address_func: TPrint_address_func;
end;

关于delphi - 相互依赖的程序变量和记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22252102/

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