2016-04-21 39 views
-5
TServiceData = class 
    strict private 
    FPriority: Integer; 
    ... 
    public 
    property Priority: Integer read FPriority write FPriority; 
    ... 
    end; 

    TMonthData = class 
    strict private 

    function GetServiceData(AIdx: Integer): TServiceData; 
    public 
    ... 
    property ServiceData: TServiceData read GetlstServiceData; // incompatible types - Why? 
    end; 

对不起。输入错误。原始我有邮件不兼容的类型

property ServiceData: TServiceData read GetServiceData; 
+0

我想知道,为什么DV? –

+0

我没有DV,但我可以尝试猜测几个潜在的原因:也许他们没有阅读基本文档?或者甚至没有给出最小的文本什么TS甚至问什么?也许是因为他没有格式化源代码并且让他们难以阅读?或者因为问题的标题没有传达任何信息?谁知道...... www.catb.org/esr/faqs/smart-questions.html –

+0

我假设你没有复制并粘贴你的实际代码?因为你有一个名为'GetServiceData'的私有方法(带有参数?),但是声明'GetlstServiceData'(IOW,不同的名字)作为getter。 –

回答

2

因为您在属性中没有参数。

property ServiceData: TServiceData read GetlstServiceData;

看到的 - 这里的GetlstServiceData可以没有参数,因为德尔福无处可他们从它的唯一可用的信息源在编译型 - 非常property ServiceData: TServiceData声明。

您应该将该参数添加到该属性或将其从该函数中删除。

TMonthData = class 
    strict private 

    function GetValue0Args(): TServiceData; 
    function GetValue1Arg(const AIdx: Integer): TServiceData; 
    function GetValue2Args(const AIdx: Integer; const Flavour: string): TServiceData; 
    public 
    ... 
    property Data0Args: TServiceData read GetValue0Args; 
    property Data1Arg[ SlotNumber: integer ]: TServiceData read GetValue1Arg; 
    property Data2Args[ SNum: integer; Recipient: string ]: TServiceData read GetValue2Args; 
    end; 

看看所谓的 “阵列属性”:http://docwiki.embarcadero.com/RADStudio/Seattle/en/Properties#Array_Properties

虽然 “阵列属性” 实际上不是阵列。这个术语选择不当:数组永远不会像字符串或对象那样将复杂的实体作为它们的索引,而属性和函数确实将它们作为可能的参数。