473,387 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Constructor Inheritance

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
Jul 4 '07 #1
1 1524
>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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Robin Forster | last post by:
I have two classes: aule_gl_window (parent class) and aule_button (sub class) I want to call the super class (parent) constructor code from the sub class constructor.
0
by: Lefevre | last post by:
Hello I recently had troubles with a class inheritance hierarchy. I solved it, but it didn't satisfied me. I found the solution using this forum :) Actualy i found the following message...
10
by: jeffc | last post by:
When compiling the following program, I get an error on the line specified: The base class "B" cannot be initialized because it does not have a default constructor. If I remove the "virtual"...
3
by: Jun | last post by:
I have following script <script> var Animal = function(name){ this.name = name; } Animal.prototype.eat = function (food) {
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
4
by: Francisco Amaro | last post by:
Hi all, Have question about inheriting a class that has parameters in the constructor such as : Public MustInherit Class MyParentClass Public mystring As String Public Sub New(ByVal...
3
by: kk_oop | last post by:
Hi. I have base class Base and derived class Derived. My derived class constructor is dependent upon attributes set in the base class constructor. Is this okay? Does ANSI C++ guarantee that a...
4
by: ingoweiss | last post by:
Hi, I am having trouble passing parameters of a Javascript subclass constructor through to it's superclass constructor. I am trying all sorts of things, including the below, but nothing...
3
by: hurcan solter | last post by:
Consider the code fragment; class A { public: A(){} A(int prm):mprm(prm){} int mprm; }; class B:public A {
11
by: Rahul | last post by:
Hi Everyone, While working with Java, i came across super() which passes values to base class constructor from derived class constructor. I was wondering if this could be implemented in c++ by...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.