[fpc-pascal] Overriding properties
pascaldragon at googlemail.com
Wed Jul 9 18:57:39 CEST 2014
Am 09.07.2014 18:43 schrieb "Timothy Groves" <the.tail.kinker at gmail.com>:
> Is there any way to override the type of a property? As an example, if I
have written a list class:
> tList = class (tObject)
> t_current : tObject;
> t_items : array of tObject;
> property Current : tObject read t_current write t_current;
> (this example is clearly not complete) and I want to create a descendant
type that uses a different object, without worrying about typecasting. Is
there a way to override Current? I tried generics, but using such renders
me unable to access the list items' properties, making it impossible to
sort the list.
Normally you simply declare the property anew in your child class. Look at
TObjectList from unit contnrs for an example.
In your specific case you'll need a Getter-method that returns
What exactly is your problem with using generics?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal