A sealed class modifiers prevents the class from getting inherited,
cases marked with sealed cannot be derived by other classes, trying to do so
will result in a complier error.
In the following example we try to define a sealed class and try to inherit the same from a derived class.
In the following example we try to define a sealed class and try to inherit the same from a derived class.
sealed class SealedBaseClass
{
}
//
class SealedDerivedClass
: SealedBaseClass
{
}
Trying to inherit a sealed class will result in the following error.
Error: 'SealedDerivedClass': cannot derive from sealed type 'SealedBaseClass'
No comments:
Post a Comment