![]() ![]() | ||
The MustInherit keyword is used to declare a class that cannot be instantiated and can be used only as a base class, also called an abstract base class. For example, in the Inheritance example on the CD-ROM, I derive two classes, Fish and Dog, from the Animal class. To make Animal an abstract class, all I have to do is to use the MustInherit keyword:
Public MustInherit Class Animal Protected MainForm As Form1 Public Sub New(ByVal form1 As Form1) MainForm = form1 End Sub Public Overridable Sub Breathing() MainForm.TextBox1.Text = "Breathing..." End Sub End Class Public Class Dog Inherits Animal ⋮ End Class Public Class Fish Inherits Animal ⋮ End Class
![]() ![]() | ||