[正确就结贴]property数组如何定义
Delphi syntax:
property Checked[Index: Integer]: Boolean;
C++ syntax:
__property bool Checked[int Index] = {read=GetChecked, write=SetChecked};
我看到Tchecklistbox中的Checked属性的帮助声明如下:
但是我在BCB中声明
__property bool Checked[int Index] = {read=GetChecked, write=SetChecked};
提示不行,
我在classexplorer中有add property,打开对话框以后会发现
最下面有一个array是不是可以声明数组呢
求教~~
[解决办法]
SetChecked和GetChecked这两个函数有没有声明啊?这是我写的一个类声明(省略函数体),没有问题。
class TSbsModules : public Classes::TOwnedCollection
{
private:
TSbsModule* __fastcall GetModuleItem(int Index);
void __fastcall SetModuleItem(int Index, TSbsModule* Value);
protected:
public:
virtual TSbsModule *__fastcall Add() { return (TSbsModule *)TCollection::Add(); }
virtual TSbsModule *__fastcall Insert(int Index) { return (TSbsModule *)TCollection::Insert(Index); }
virtual TSbsModule *__fastcall GetItem(int Index) { return Items[Index]; }
__property TSbsModule* Items[int Index] = {read=GetModuleItem, write=SetModuleItem };
virtual TSbsModule* operator[](int Index) { return Items[Index]; }
inline __fastcall TSbsModules(TPersistent* AOwner, TMetaClass* ItemClass) : TOwnedCollection(AOwner, ItemClass) { }
inline __fastcall ~TSbsModules() { }
};