[fpc-pascal] override and virtual: was SetFileTime

Steve Litt slitt at troubleshooters.com
Thu May 4 03:04:15 CEST 2023


Giuliano Colla via fpc-pascal said on Wed, 3 May 2023 19:33:25 +0200


>
>    Override: When you're dealing with objects, you have the
>    inheritance, that is you may derive a new class (the template of an
>    object) from an existing class and the newly created class inherits
>    all the methods and properties of the parent class. In this case
>    TTouchJunction is declared as a descendant of TCustomApplication,
>    therefore it inherits all the methods and properties. If you need
>    that your object does something different from the methods of its
>    parent, but keep the same name, you must declare that your
>    declaration overrides the ancestors one. If in the body of your new
>    method if you want to execute also the ancestor method you may call
>    it with the keyword "inherited".
>
>  *
>
>    Virtual: means that this method can be overridden by a descendant
>    class. The same does the keyword Dynamic.  The difference has to do
>    with the way the code is allocated in memory. Virtual is optimized
>    for speed, Dynamic for memory.
>
>Hope that it helps.

Thanks Giuliano, it helps a lot. I'm familiar with the concepts you
mentioned from work with Perl, Python and C++, and it's good to know
how they're implemented in FPC.

Thanks,

SteveT

Steve Litt 
Autumn 2022 featured book: Thriving in Tough Times
http://www.troubleshooters.com/bookstore/thrive.htm


More information about the fpc-pascal mailing list