[fpc-pascal] use of "inherited" keyword

Sven Barth pascaldragon at googlemail.com
Wed Nov 13 09:35:56 CET 2013


Am 13.11.2013 02:57, schrieb Xiangrong Fang:
> Hi,
>
> Is it OK to use "inherited" in any instance method? i.e.
>
> It is OK to do this:
>
> procedure TChildClass.DoIt;//override
> begin
>   inherited DoIt;
> end;
>
> But is it ok to do this:
>
> procedure TChildClass.SomethinElse;//NOT DoIt
> begin
>   inherited DoIt;
>   //... ...
> end;
>
> I tried, it seems ok, but I am not sure, because I had a strange 
> access violation in my code which I cannot reproduce in simplified 
> version of the code, so I suspect this might be an invalid use and 
> "correct by coincidence"?
You can always use "inherited" to call a method of the given name in the 
next parent class that has such a method (Note: there are a few 
exceptions: If no such methods exist (compile time error) and if the 
method is abstract (also compile time error))

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20131113/00ff0203/attachment.html>


More information about the fpc-pascal mailing list