I have three classes Employee, Manager and Salesman. Manager and Salesman classes inherits Employee class.
Employee :
Public MustInherit Class Employee
' Field data.
Protected empName As String
Protected empID As Integer
Protected currPay As Single
' Constructors
Public Sub New()
End Sub
Public Sub New(ByVal name As String, ByVal id As Integer, ByVal pay As Single)
empName = name
empID = id
currPay = pay
End Sub
End Class
Manager :
Public Class Manager
Inherits Employee
Private Dept As String
Sub New()
End Sub
Sub New(ByVal name As String, ByVal id As Integer, ByVal pay As Single, ByVal dept As String)
MyBase.New(name, id, pay)
Me.Dept = dept
End Sub
End Class
Salesman :
Public Class Salesman
Inherits Employee
Private noOfSales As Integer
Sub New()
End Sub
Sub New(ByVal name As String, ByVal id As Integer, ByVal pay As Single, ByVal sales As Integer)
MyBase.New(name, id, pay)
Me.noOfSales = sales
End Sub
End Class
Now I have created a object of salesman and manager using the following code.
Dim objSalesMan as Employee=new Salesman("xyz",1,2000,5000)
Dim objManager as Employee=new Manager("abx",2,5000,"production")
Is this a good programming pratice or should I use
Dim objSalesMan as new Salesman("xyz",1,2000,5000)
Dim objManager as new Manager("abx",2,5000,"production")
I am confused. Can someone point me in a right direction ?
Thanks.
This post has been edited by Searock: 27 July 2010 - 12:48 PM

New Topic/Question
Reply




MultiQuote





|