473,408 Members | 2,052 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,408 software developers and data experts.

Inherited functions not visible?

Hi,

I've created a MasterForm which all my forms in my project must derive from.

In my MasterForm, I've overloaded the New event with this code:
Public Sub New(ByVal SomeText As String)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call
'Do something with SomeText...
End Sub
I've add an inherited form MyForm which inherits from my MasterForm.

Here's my question....

Why can't I write Dim MyNewForm As New MyForm("Just a test") ?

The overloaded New(ByVal SomeText As String) is not visible when I'm
creating a new MyForm (which inherits from MasterForm).

What am I doing wrong?

Thanks.

M O J O

Nov 20 '05 #1
3 1237
"M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> schrieb
Hi,

I've created a MasterForm which all my forms in my project must
derive from.

In my MasterForm, I've overloaded the New event with this code:
Public Sub New(ByVal SomeText As String)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent()
call 'Do something with SomeText...
End Sub
I've add an inherited form MyForm which inherits from my
MasterForm.

Here's my question....

Why can't I write Dim MyNewForm As New MyForm("Just a test") ?

The overloaded New(ByVal SomeText As String) is not visible when I'm
creating a new MyForm (which inherits from MasterForm).

What am I doing wrong?


Constructors are not inherited. They can not be inherited because the
constructor is tied to the specific instance of a class. In other words, the
constructors determine how you can create an instance of the class they
belong to.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
M O J O
In addition to Armin's comments.

Constructors are never inherited! As you may have the case where the derived
class requires a different set of constructors then the base class, hence it
is left up to the designer of the derived class to implement the correct set
of constructors for the derived class.

Basically its (IMHO) "cleaner" to need to add the constructors you need to
the derived class, rather then have some syntax to remove constructors that
may have been inherited and you don't need, especially when a new
constructor could be added to the base, and you missed "removing" that
constructor from the derived class...

You sample reminds me that the base form needs to call the base form's
InitializeComponent, and the derived form needs to call the derived form's
InitializeComponent! Which further highlights why constructors are never
inherited.

Hope this helps
Jay

"M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

I've created a MasterForm which all my forms in my project must derive from.
In my MasterForm, I've overloaded the New event with this code:
Public Sub New(ByVal SomeText As String)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call
'Do something with SomeText...
End Sub
I've add an inherited form MyForm which inherits from my MasterForm.

Here's my question....

Why can't I write Dim MyNewForm As New MyForm("Just a test") ?

The overloaded New(ByVal SomeText As String) is not visible when I'm
creating a new MyForm (which inherits from MasterForm).

What am I doing wrong?

Thanks.

M O J O

Nov 20 '05 #3
Thanks!

So it's not me going crazy! :o))

M O J O

Armin Zingler wrote:
"M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> schrieb
Hi,

I've created a MasterForm which all my forms in my project must
derive from.

In my MasterForm, I've overloaded the New event with this code:
Public Sub New(ByVal SomeText As String)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent()
call 'Do something with SomeText...
End Sub
I've add an inherited form MyForm which inherits from my
MasterForm.

Here's my question....

Why can't I write Dim MyNewForm As New MyForm("Just a test") ?

The overloaded New(ByVal SomeText As String) is not visible when I'm
creating a new MyForm (which inherits from MasterForm).

What am I doing wrong?

Constructors are not inherited. They can not be inherited because the
constructor is tied to the specific instance of a class. In other words, the
constructors determine how you can create an instance of the class they
belong to.


Nov 20 '05 #4

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

Similar topics

2
by: Daniel Barna | last post by:
Hi I am a bit confused. I thought always that if a class inherits from another (public), then all of its base class's public member function are also visible in this class - even if it declares a...
8
by: ashok | last post by:
I have a confusion. Do static member functions of base class get inherited to derived class? I searched for this answer but nowhere I get any referencec saying "derived class inherits static...
4
by: Fabio Cannizzo | last post by:
Is there a way to hide an inherited protected member so that it is no longer accessible nor visible from the inherited classes? The code below makes c1.foo() no longer accessible, but c2.foo is...
3
by: Gene Hubert | last post by:
I've got a custom datagrid that inherits from the standard datagrid on a windows form. I expected that since it is an inherited object, protected properties from the standard datagrid would be...
4
by: asad.naeem | last post by:
hi to all this is the problem about inheritence. I have designed a form with some essential controls which are required for every form which will inherited from it. for example i have Button1 on...
5
by: Shak | last post by:
Hi all. I was led to believe that static methods were not inherited by their subclasses (and since that makes sense, rightly so). However, a subclass I've written is using it's (abstract)...
14
by: lovecreatesbea... | last post by:
Could you tell me how many class members the C++ language synthesizes for a class type? Which members in a class aren't derived from parent classes? I have read the book The C++ Programming...
0
by: SM | last post by:
Hi, #1 I did some changes in my inherited form (change some properties of my components), now I want to rollback all changes made in inherited form and return to the same state as the...
13
by: PragueExpat | last post by:
I (think) that I've come up with a pattern that I haven't seen in any publications so far and I would like some feedback. Basically, I was looking for a way to inherit private functions and I came...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.