Announcement

Collapse
No announcement yet.

How can we restrict inheritance for a class?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Kajal
    started a topic How can we restrict inheritance for a class?

    How can we restrict inheritance for a class?

    How can we restrict inheritance for a class?

  • parulsharma
    replied
    In a base class, the sealed keyword is only used to prevent a class from being derived, but in inherited classes it can be used to prevent another inherited class from overriding the method. ... In the example you provided, class B could not override methodB because methodB was not marked as virtual on the original class.

    Leave a comment:


  • Randy
    replied
    The main reason to prevent inheritance is to make sure the way a class behaves is not corrupted by a subclass.

    Leave a comment:

Working...
X