Can you prevent your class from being inherited and becoming a base class for some other classes?

Can you prevent your class from being inherited and becoming a base class for some other classes?

Yes,we can prevent class from being inherited by using sealed class, keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class Whatever BaseClassName. It is the same concept as final class in Java. 

By:
Date:2011-10-10 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related C Links

C interview questions and answers for experienced and fresher