Final class
Daniel Kozak
kozzi11 at gmail.com
Thu Jul 11 22:47:24 PDT 2013
On Friday, 12 July 2013 at 05:13:44 UTC, Jonathan M Davis wrote:
> On Friday, July 12, 2013 07:03:07 Daniel Kozak wrote:
>> Are all methods in final class non-virtual or must be explicity
>> marked as a final too?
>
> They're virtual if they override base class functions, but
> they're definitely
> all final. So, the compiler _should_ optimize the functions in
> a final class
> which don't override anything so that they're non-virtual.
> However, I'm not
> sure that there's actually any guarantee that final methods
> which don't
> override anything will actually be made non-virtual. It's an
> optimization
> based on the fact that the compiler can determine that it can
> be made non-
> virtual rather than it explicitly being made non-virtual by the
> programmer, so
> the compiler might not do it. It _should_, but I'm not sure
> that it's
> guaranteed to.
>
> - Jonathan M Davis
Thanks
More information about the Digitalmars-d-learn
mailing list