spir wrote: > -2- [] operator > How to implement a class that manages this operator (did not find it > in the operator overloading section). Pointer welcome (including to > the implementation of eg TFPList).
It seems default properties is what you are looking for. >> type >> TMyClass = class >> ... >> property Items[AnIndex: Integer]: TMyItem read GetItem write SetItem; >> default; Note the "default" keyword, it allows you to access Items like this: >> MyClassInstance[1] instead of >> MyClassInstance.Items[1] You can also use string instead of Integer index, then accessing such property would look like dealing with associative arrays: >> MyClassInstance['first'] or >> MyClassInstance.Items['first'] GetItem and SetItem methods must take the appropriate parameters, and return the appropriate result. You can let Lazarus generate them for you by declaring the property and pressing Ctrl+C while cursor is on the same line with your property declaration. -- Regards, Vladimir Zhirov _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal