Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does an inherited class automatically implement an Interface from its base class?

Suppose I have piece of code like this:

Public Interface ISomething
    ....
End Interface

Public Class SomeClass
  Implements ISomething
    ....
End Class

Now, if I inherit from SomeClass like this:

Public Class InheritedClass
  Inherits SomeClass
    ....
End Class

will InheritedClass automatically implements ISomething, or must I use Implements ISomething in the InheritedClass' definition?

like image 705
pepoluan Avatar asked Dec 12 '22 12:12

pepoluan


2 Answers

The interface was already implemented by the base class. Your derived class will thus implement it as well since it inherits the base class implementation. If you want to alter the base class implementation then you should declare the implementation method(s) virtual so you can override them.

like image 189
Hans Passant Avatar answered May 18 '23 14:05

Hans Passant


Yes, the interface will be inherited as well.

like image 42
Edwin de Koning Avatar answered May 18 '23 15:05

Edwin de Koning