gpt4 book ai didi

class - Delphi : Error 2008 Incompatible types for a class property

转载 作者:行者123 更新时间:2023-12-03 19:31:03 24 4
gpt4 key购买 nike

我定义了这个类

  TParamType = (ptDriverID, ptServer, ptHost, ptUser, ptPassword, ptPort, ptDatabase, ptOSAuth, ptPooled, ptUnicode);
TDataType = (dtInteger, dtString, dtBoolean, dtYesNo, dtPassword);


TParam = record
Index: Byte;
Typ: TParamType;
RegKeyName: String;
ConnName: String;
DataType: TDataType;
Caption: String;
Value: String;
Text: String;
Default: String;
Basic: Boolean;
Enabled: Boolean;
Mandatory: Boolean;
end;

TParams = class(TObject)
private
FParam: array of TParam;
function GetParam(Index:Byte): TParam;
procedure SetParam(Index:Byte;Value:String;Text:String);
public
constructor Create;
destructor Destroy;
property Param[Index: Byte]: TParam read GetParam write SetParam;
procedure Enable(ServerType:TServerType);
end;

我收到此错误:代码行出现“E2008不兼容类型”
property Param[Index: Byte]: TParam read GetParam write SetParam;

知道为什么我会为此属性收到此错误吗?

最佳答案

property ParamTParam。因此,SetParam需要将Index接收到数组中,然后将TParam放入数组中。您的setter会提供索引和两个字符串,都不是TParam

合适的二传手是

procedure SetParam(Index: Byte; const Value: TParam);

关于class - Delphi : Error 2008 Incompatible types for a class property,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21369445/

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