We create sealed class when we want to restrict or prevent the class to be inherited. Sealed modifier is used to prevent derivation from a class. If we try to specify a sealed class as base class then a compile-time error occurs.
If we try to inherit sealed class then following error well be occure
class MyDerivedC: SealedClass {} // Error
The result is an error message:
'MyDerivedC' cannot inherit from sealed class 'SealedClass'.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
We create sealed class when we want to restrict or prevent the class to be inherited. Sealed modifier is used to prevent derivation from a class. If we try to specify a sealed class as base class then a compile-time error occurs.
If we try to inherit sealed class then following error well be occure
class MyDerivedC: SealedClass {} // Error
The result is an error message:
'MyDerivedC' cannot inherit from sealed class 'SealedClass'.