On 2014-03-22 22:34, hinsta...@yandex.ru wrote:
What you do this for? Using override directive makes no sense in this case, so 
I suggest you just don't use it. If you don't use it, the descendant enumerator 
will still work like intended
I Think override makes perfect sense in this case.

I get to only implement the GetCurrent procedure once, the example is simplified but in my real-world application it does some additional structure checking, and in all derived classes i get to call the ancestor method but return an object of the type i need.

If I could not override the code for GetCurrent the following

forBar inBarList do
    Bar.Val2:=1;

would not be able to know the Bar is a TBar, but would rather see Bar as a pointer (since in this case it inherits from TList). And all subsequent code would have to do some sort of typecasting.

I hope that makes a little bit of sense...

Regards,
Torsten.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to