Final class

Jonathan M Davis jmdavisProg at gmx.com
Thu Jul 11 22:13:34 PDT 2013


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


More information about the Digitalmars-d-learn mailing list