
Public MustInherit Class Employee
Private mFirstName As String ‘Employee first name
Private mLastName As String ‘Employee last name
Public Sub New(ByVal fname, ByVal lname)
mFirstName = fname
mLastName = lname
End Sub
Public Property FName() As String
Get
Return mFirstName
End Get
Set(ByVal value As String)
mFirstName = value
End Set
End Property
Public Property LName() As String
Get
Return mLastName
End Get
Set(ByVal value As String)
mLastName = value
End Set
End Property
Public MustOverride Function InComeEarned() As Double
End Class
Implementing Abstract Class
Public Class RegularEmployee
Inherits Employee
End Class
When a class is inherited from an abstract class, it must implement every abstract member defined by the abstract class. Refer the code given above. The method InComeEarned() is declared as an abstract member in abstract class – ‘Employee’, we have implemented this method using the Overrides keyword as shown below.
Public Class RegularEmployee
Inherits Employee
Private mSalary As Double
Public Sub New(ByVal fname, ByVal lname, ByVal salary)
MyBase.New(fname, lname)
mSalary = salary
End Sub
Public Property Salary() As String
Get
Return mSalary
End Get
Set(ByVal value As String)
mSalary = value
End Set
End Property
Public Overrides Function InComeEarned() As Double
Return Salary()
End Function
End Class
Copyright © 2012 - All Rights Reserved - VKInfotek.com