Constructor Inheritance

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
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top