I was reading through the UE4 coding standards and came up to the encapsulation section. In there it says:
Use final if your class is not designed to be derived from.
I’m not very familiar using final specifiers, I used final for a derived UUWidget class since I will definitely not extend it, like so:
class HOTK_API UHKServerMenu final : public UUserWidget
My question is, shouldn’t there be a compiler error since there is a blueprint class extending from my final class? I’m mostly implementing my C++ functions to be used by the widget blueprint as bindings.
C++ documentation states:
When used in a class definition, final specifies that this class may not appear in the base-specifier-list of another class definition (in other words, cannot be derived from). The program is ill-formed (a compile-time error is generated) otherwise. final can also be used with a union definition, in which case it has no effect (other than on the outcome of std::is_final), since unions cannot be derived from)
Still my game works completely fine and I’m not getting compiler errors or undefined behaviors.