473,836 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

strange inheritance proble

Dear all,
class A
overridable sub s1(byval a as integer)
end sub
overridable sub s2(byval a as integer, byval b as integer)
end sub
end class

class B
inherits class A
overrides sub s1(byval a as integer)
end sub
end class

s1 in both classes is public and has the same signature, but VB complains s1
in B can't be declared as overrides ... blabla use overload?
What is wrong here?
Thanks,
Boni
Nov 21 '05 #1
8 1251
Boni,

Did you try it already with this
inherits class A

inherits A

I hope this helps,

Cor
Nov 21 '05 #2
Post the actual code, not your shortened, off the top of your head, version
of it. And post the actual error message, not "blabla"

Maybe then, some of us can be of more assistance.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Boni" <oilia@nospam > wrote in message
news:uY******** ******@TK2MSFTN GP12.phx.gbl...
Dear all,
class A
overridable sub s1(byval a as integer)
end sub
overridable sub s2(byval a as integer, byval b as integer)
end sub
end class

class B
inherits class A
overrides sub s1(byval a as integer)
end sub
end class

s1 in both classes is public and has the same signature, but VB complains
s1 in B can't be declared as overrides ... blabla use overload?
What is wrong here?
Thanks,
Boni

Nov 21 '05 #3
Actual code:
Module Module1

Class A

Overridable Sub s1(ByVal a As Integer)

End Sub

Overridable Sub s1(ByVal a As Integer, ByVal b As Integer)

End Sub

End Class

Class B

Inherits A

Overrides Sub s1(ByVal a As Integer)

End Sub

End Class

Sub Main()

End Sub

End Module

(11) : warning BC40003: sub 's1' shadows an overloadable member declared in
the base class 'A'. If you want to overload the base method, this method
must be declared 'Overloads'.

WARNING: sub 's1' shadows an overloadable member declared in the base class
'A'. If you want to overload the base method, this method must be declared
'Overloads'.

Why b::s1 can't override A::S1
Nov 21 '05 #4
Hi,
Why b::s1 can't override A::S1


It can, why not? 8=]

But since you have two s1's in base class, you need to mark s1 from derived
class with Overloads to show you are still overloading, as compiler
suggests.

HTH

Roman
Nov 21 '05 #5
But between overrides and overloads there is a big difference. Look in main
of following example. A::s1 is called where I want B::s1 to be called (just
as an example 2).
Please could somebody to help me to find a solution for that strange
problem.
Example 1:
Module Module1
Class A

Overridable Sub s1(ByVal a As Integer)

Console.WriteLi ne("A")

End Sub

Overridable Sub s1(ByVal a As Integer, ByVal b As Integer)

End Sub

End Class

Class B

Inherits A

Overloads Sub s1(ByVal a As Integer)

Console.WriteLi ne("B")

End Sub

End Class

Sub Main()

Dim oB As New B

Dim pA As A = oB

pA.s1(110)

End Sub

End Module

Example2:

Module Module1

Class A

Overridable Sub s1(ByVal a As Integer)

Console.WriteLi ne("A")

End Sub

End Class

Class B

Inherits A

Overrides Sub s1(ByVal a As Integer)

Console.WriteLi ne("B")

End Sub

End Class

Sub Main()

Dim oB As New B

Dim pA As A = oB

pA.s1(110)

End Sub

End Module
Nov 21 '05 #6
Ehh, it seems that you misunderstood me.

You shouldn't replace Overrides by Overloads, but just add Overloads
modifier, e.g.:

~
Overloads Overrides Sub s1(ByVal a As Integer)

Console.WriteLi ne("B")

End Sub

~

Try to change example 1 this way and it will work fine.
Nov 21 '05 #7
Thanks!!! You are right. But I must say it makes no sence for me :) . I
don't understand why it is done like this.
Why only overrides was not enougth for VB inventors?
"Dragon" <no@spam.please > schrieb im Newsbeitrag
news:um******** ******@TK2MSFTN GP10.phx.gbl...
Ehh, it seems that you misunderstood me.

You shouldn't replace Overrides by Overloads, but just add Overloads
modifier, e.g.:

~
Overloads Overrides Sub s1(ByVal a As Integer)

Console.WriteLi ne("B")

End Sub

~

Try to change example 1 this way and it will work fine.

Nov 21 '05 #8
> I don't understand why it is done like this.

Nor do I. 8=0]

Probably, the logic was: if you override an Overloads member then your
method must be declared Overloads too.
Why only overrides was not enougth for VB inventors?


You better should ask VB inventors. ;ó)
Nov 21 '05 #9

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

Similar topics

1
5978
by: pintur | last post by:
The message is: SQL1036C Errore di I/O durante l' accesso al database. SQLSTATE=58030 what is the proble? what for restore tables? thanks
2
1311
by: Andrew | last post by:
hi, here is my code : szQry = "SELECT SubCategory_ID , " & _ " Loc1.Description as Descrizione " & _ " FROM C_SubCategories " & _ " LEFT OUTER JOIN D_Localizations Loc1 " & _ " ON ( C_SubCategories.Description_ID = Loc1.Localization_ID AND Loc1.Language_ID = @LanguageID ) " & _ " WHERE Category_ID = @CategoryID " & _ " AND StateActive = 1 " & _
6
1772
by: Peter Oliphant | last post by:
I just discovered that the ImageList class can't be inherited. Why? What could go wrong? I can invision a case where someone would like to add, say, an ID field to an ImageList, possible so that the individual elements in an array of ImageList's could be identified by the ID, thereby allowing re-ordering the array without harm. A person could identify by index into the array, but that would not be preserved by re-ordering (and re-ordering...
8
1166
by: Peter | last post by:
The stylesheet submitted for checking by W3C gives 2 warnings. no color for background. But the backgroudcolor is given. What can be wrong? This is the stylesheet: http://lehmann.fateback.com/lehmann.css -- http://lotto924.fateback.com
4
1847
by: tony | last post by:
Hello! My question is about calling this method CollectData below but I get a compile error that I shouldn't have because the type parameter is correct. The compile error is the following: C:\PK\Development\Products\UTCAS\4.0\SRC\MeltPracApplication\Dialog\Composit ionForm.cs(942): Argument '1': cannot convert from 'ref MeltPracData.MeltPracDataComposition' to 'ref MeltPracCommon.IDialogPostData'
6
1307
by: Andrew Ducker | last post by:
I have a class "Validator" which can be cast to a Control. The code: ValidTextBox t = (ValidTextBox)v; works just fine. However, because v doesn't descend from t, I can't use "is" or "as". I did want a safe way of casting though - so I tried the following code: public static T ConvertClass<T>(Validator myValidator) where T : Control {
6
1732
by: ralphmerridew | last post by:
My current project involves reading a particular data format. It would be convenient to be able to do something like: class DataClass { friend bool FileRunner::read_data (const vector<string>&); ... }; class OtherDataClass {
8
1687
by: matthewperpick | last post by:
Check out this toy example that demonstrates some "strange" behaviour with keyword arguments and inheritance. ================================= class Parent: def __init__(self, ary = ): self.ary = ary def append(self):
21
2488
by: raylopez99 | last post by:
Well, contrary to the implication in my 2000 textbook on C# (public beta version), C# does allow multiple inheritance, so long as it's serially chained as follows: class derived02 : derived01 { } class derived01 : baseclass01
12
5659
Dormilich
by: Dormilich | last post by:
Hi, I’ve encountered quite a strange error when loading one of my scripts in Safari (4.0.3/Mac): I have no idea, what Safari is complaining about, since it works in FF 3.5 and Opera 10, does anyone of you have an idea? thanks, Dormi // by Gavin Kistner
0
9820
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9670
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10548
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10591
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5649
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4016
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.