Constructor Inheritance

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

VB.NET VS 2005.
I have a Form1 Base Class with one default and one overload constructor:
Sub New
InitializeComponent
End Sub

Sub New( ByVal A as Int32)
me.new
me.a = A
End Sub

Then I have a Form2 inheriting from Form1

But if i try to call:
Dim f As New Form2(A)
VS say that there are too many arguments for *Public Sub New()*

Why?
How can i inherit the constructor ?

The only way i found is to write another constructor in the derived class
like this:
Sub New(A)
Mybase.New(A)
Initializecomponent()
End Sub
 
Why?
How can i inherit the constructor ?

You can't, constructors are never inherited. As you've already figured
out, you must redefine a constructor with the same signature in the
derived class if you want it.


Mattias
 
Back
Top