Help with inheritence

RaNdOmGuY

New member
Joined
Feb 28, 2006
Messages
2
Location
Australia, Victoria, East Coast
Programming Experience
Beginner
Hi, i'm very new to vb.net and am having some trouble with inheritence... to start off i'm not sure if the code i am using is for one: inheriting the information correctly and two: overriding it correctly and three: displaying it correctly, i get no errors which makes it harder to judge if i am on the right path...

basically i need to override employee.vb, add 1000 to mintID and then display mintID

any help is much appreciated

employee.vb (below are only the sections i am trying to inherit from)
VB.NET:
Public Sub New(ByVal name As String, ByVal salary As Double)
  mstrName = name
  mdblSalary = salary
  mCounter += 1
  mintID = 1000 + mCounter
    End Sub

    ReadOnly Property ID() As Integer
  Get
    Return mintID
  End Get
End Property
Developer.vb
VB.NET:
 Public Class Developer
  Inherits Employee

  Public Sub New(ByVal name As String, ByVal salary As Double)
    MyBase.New(name, salary)
    mintID += 1000
  End Sub

  Overloads ReadOnly Property ID() As Integer
    Get
      Return mintID
    End Get
  End Property

End Class
 
Last edited by a moderator:
Your ID property should be declared Public in Employee. You cannot overload it like that and there is no need to override it. Just call it on an instance of either class and it will return the appropriate value.
 
Back
Top