J
Jon
I'm running into a simple issue when instatiating a derived class that
calls a custom constructor. Here's the type of code found in the
parent class:
Public Class parent
Private _a As Long
Private _b As Long
Private _c As String
.....
Public Sub New(ByVal a As Long, ByVal b As Long, ByRef c As
String)
_a = a
_b = b
_c = c
EndSub
EndClass
And now the derived class:
Public Class child
Inherits parent
' apparently, i have to redeclare the private vars found in the
parent???
Private _a As Long
Private _b As Long
Private _c As String
.....
' cannot inherit the constructor, so define identical one here
Public Sub New(ByVal a As Long, ByVal b As Long, ByRef c As
String)
' call mybase.new to assign vars
MyBase.New(a, b, c)
EndSub
EndClass
By calling 'mybase.new' in the child class, I had expected the var
assignments in the parent to be executed, populating the vars declared
in the child.
What I found with the above class definitions is that the child 'var
_c' is NOT assigned a value.
I'm sure there's a simple answer, but I'm a beginner. Also, I found
some MSDN articles on class inheritance in the 'Upgrading to .NET'
section, but am looking for something that goes deeper. Any idea
where I can find articles that go into greater depth on the subject of
class inheritance?
Thanks... Jon
calls a custom constructor. Here's the type of code found in the
parent class:
Public Class parent
Private _a As Long
Private _b As Long
Private _c As String
.....
Public Sub New(ByVal a As Long, ByVal b As Long, ByRef c As
String)
_a = a
_b = b
_c = c
EndSub
EndClass
And now the derived class:
Public Class child
Inherits parent
' apparently, i have to redeclare the private vars found in the
parent???
Private _a As Long
Private _b As Long
Private _c As String
.....
' cannot inherit the constructor, so define identical one here
Public Sub New(ByVal a As Long, ByVal b As Long, ByRef c As
String)
' call mybase.new to assign vars
MyBase.New(a, b, c)
EndSub
EndClass
By calling 'mybase.new' in the child class, I had expected the var
assignments in the parent to be executed, populating the vars declared
in the child.
What I found with the above class definitions is that the child 'var
_c' is NOT assigned a value.
I'm sure there's a simple answer, but I'm a beginner. Also, I found
some MSDN articles on class inheritance in the 'Upgrading to .NET'
section, but am looking for something that goes deeper. Any idea
where I can find articles that go into greater depth on the subject of
class inheritance?
Thanks... Jon