Menu

keywords-final

Will Pittenger

This can either prevent other types from deriving from this type or prevents those types from overriding a virtual method or property. For more information, see the sections [Derivation] and [Members and methods].

Final types

A type that's final can't be used as a base type by another type. Place it just before class/struct keyword. All enum types are implicitly final.

/AccessQualifierIfNeeded/ \final\ (\struct\ | \class\) /RestOfTypeDeclaration/

If your type is part of another type or a namespace, you must use /AccessQualifierIfNeeded/ to specify public, protected, or private. Otherwise, access qualifiers aren't allowed. For what to put where /RestOfTypeDeclaration/ appears in the sample above, see struct and class.

Final methods and properties

If you declare a method or property as final, types that derive from yours can't override it without the new keyword. final methods and properties are normally, but don't have to be, virtual. To make final a command, function, complex statement, or property; place the final keyword immediately before the command/function/statement/property keyword. To declare a property accessor as final, place the final keyword immediately before the get/set keyword.

/AccessQualifierIfNeeded/ \final\ (\command\ | \function\ | \statement\ | \property\ | \get\ | \get\) /RestOfDeclaration/

Commands, functions, complex statements, and properties require that /AccessQualifierIfNeeded/ evaluate to "(\public\ | \protected\ | \private\)". Property accessors don't require an access qualifier, but if your circumstances require one, add public, protected, or private as needed.


Related

Wiki: Derivation
Wiki: Keywords
Wiki: Members and methods
Wiki: Type casts
Wiki: keywords-class
Wiki: keywords-command
Wiki: keywords-enum
Wiki: keywords-function
Wiki: keywords-get
Wiki: keywords-new
Wiki: keywords-private
Wiki: keywords-property
Wiki: keywords-protected
Wiki: keywords-public
Wiki: keywords-set
Wiki: keywords-statement
Wiki: keywords-virtual