I've got a good question about object-oriented programming, I hope I can explain it well enough. I'm creating a UserManager, which I'm going to inherit from so different applications can share common methods.
Public MustInherit Class UserManager
Public MustOverride Sub AddUser(usr as InternetUser)
End Class
Public Class InternetUser
Public username as string
End Class
--
Ok so now I need my specific application "Blah" to inherit from these methods. My PROBLEM comes with this InternetUser type. My new appliation is extending this InternetUser type as well, so this MustOverride method AddUser needs to be changed to accept a "BlahUser" now. Since a BlahUser IS A InternetUser, I would think I can do this somehow.
Public Class BlahUser : Inherits InternetUser
End Class
Public Class BlahUserManager : Inherits UserManager
'my problem is what can I do when it comes to overriding the Sub "AddUser", since I'm now using BlahUser's, I'm getting compiler errors
Public Overrides Sub AddUser(usr as BlahUser) '<-- getting a compiler error here, since signature doesn't match parent.
End Sub
End Class
How can I successfully override this sub, but change the signature of the sub? I'd really like to have either an Interface or MustOverride Subs/Methods. I know I can use shadows, but that really seems like a cop out way of doing things, and I'm throwing out polymorphism when I do it.
I hope this is clear enough!, perhaps I'm just way off the mark here about how to do something like this, but I would almost think this should be able to be done.
Thanks for any help!
--Michael 7 1886
Tye Overloads instead of overrides as they are different types ( BlahUsr and
InternetUser )
--
OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1)
Next
Process.Start(" mailto:" & New String(ch))
--
"Raterus" <mo*********@su retar.reverse> wrote in message
news:OI******** ******@tk2msftn gp13.phx.gbl...
I've got a good question about object-oriented programming, I hope I can
explain it well enough. I'm creating a UserManager, which I'm going to
inherit from so different applications can share common methods.
Public MustInherit Class UserManager
Public MustOverride Sub AddUser(usr as InternetUser)
End Class
Public Class InternetUser
Public username as string
End Class
--
Ok so now I need my specific application "Blah" to inherit from these
methods. My PROBLEM comes with this InternetUser type. My new appliation
is extending this InternetUser type as well, so this MustOverride method
AddUser needs to be changed to accept a "BlahUser" now. Since a BlahUser IS
A InternetUser, I would think I can do this somehow.
Public Class BlahUser : Inherits InternetUser
End Class
Public Class BlahUserManager : Inherits UserManager
'my problem is what can I do when it comes to overriding the Sub
"AddUser", since I'm now using BlahUser's, I'm getting compiler errors
Public Overrides Sub AddUser(usr as BlahUser) '<-- getting a compiler
error here, since signature doesn't match parent.
End Sub
End Class
How can I successfully override this sub, but change the signature of the
sub? I'd really like to have either an Interface or MustOverride
Subs/Methods. I know I can use shadows, but that really seems like a cop
out way of doing things, and I'm throwing out polymorphism when I do it.
I hope this is clear enough!, perhaps I'm just way off the mark here about
how to do something like this, but I would almost think this should be able
to be done.
Thanks for any help!
--Michael
"Raterus" <mo*********@su retar.reverse> schrieb: Public MustInherit Class UserManager Public MustOverride Sub AddUser(usr as InternetUser) End Class
Public Class InternetUser Public username as string End Class
--
Ok so now I need my specific application "Blah" to inherit from these methods. My >PROBLEM comes with this InternetUser type. My new appliation is extending this >InternetUser type as well, so this MustOverride method AddUser needs to be changed to >accept a "BlahUser" now. Since a BlahUser IS A InternetUser, I would think I can do this >somehow.
Public Class BlahUser : Inherits InternetUser
End Class
Public Class BlahUserManager : Inherits UserManager 'my problem is what can I do when it comes to overriding the Sub "AddUser", since I'm now using BlahUser's, I'm getting compiler errors
Public Overrides Sub AddUser(usr as BlahUser) '<-- getting a compiler error here, since >signature doesn't match parent.
End Sub End Class
\\\
Public Class InternetUser
'
End Class
Public Class BlaUser
Inherits InternetUser
'
End Class
Public MustInherit Class UserManager
Public MustOverride Sub AddUser(ByVal usr As InternetUser)
End Class
Public Class BlahUserManager
Inherits UserManager
Public Overloads Sub AddUser(ByVal usr As BlaUser)
'
End Sub
Public Overloads Overrides Sub AddUser(ByVal usr As InternetUser)
'
End Sub
End Class
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
thanks, this is what I needed!
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message news:OJ******** ******@TK2MSFTN GP14.phx.gbl... "Raterus" <mo*********@su retar.reverse> schrieb:Public MustInherit Class UserManager Public MustOverride Sub AddUser(usr as InternetUser) End Class
Public Class InternetUser Public username as string End Class
--
Ok so now I need my specific application "Blah" to inherit from these methods. My >PROBLEM comes with this InternetUser type. My new appliation is extending this >InternetUser type as well, so this MustOverride method AddUser needs to be changed to >accept a "BlahUser" now. Since a BlahUser IS A InternetUser, I would think I can do this >somehow.
Public Class BlahUser : Inherits InternetUser
End Class
Public Class BlahUserManager : Inherits UserManager 'my problem is what can I do when it comes to overriding the Sub "AddUser", since I'm now using BlahUser's, I'm getting compiler errors
Public Overrides Sub AddUser(usr as BlahUser) '<-- getting a compiler error here, since >signature doesn't match parent.
End Sub End Class \\\ Public Class InternetUser ' End Class Public Class BlaUser Inherits InternetUser ' End Class Public MustInherit Class UserManager Public MustOverride Sub AddUser(ByVal usr As InternetUser) End Class Public Class BlahUserManager Inherits UserManager Public Overloads Sub AddUser(ByVal usr As BlaUser) ' End Sub Public Overloads Overrides Sub AddUser(ByVal usr As InternetUser) ' End Sub End Class /// -- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
I had even thought to do that, but never went as far as to try, thanks!
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message news:Oy******** ******@TK2MSFTN GP12.phx.gbl... Tye Overloads instead of overrides as they are different types ( BlahUsr and InternetUser ) -- OHM ( Terry Burns ) * Use the following to email me * Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y() For i As Int32 = 0 To ch.Length - 1 ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1) Next Process.Start(" mailto:" & New String(ch)) -- "Raterus" <mo*********@su retar.reverse> wrote in message news:OI******** ******@tk2msftn gp13.phx.gbl... I've got a good question about object-oriented programming, I hope I can explain it well enough. I'm creating a UserManager, which I'm going to inherit from so different applications can share common methods. Public MustInherit Class UserManager Public MustOverride Sub AddUser(usr as InternetUser) End Class Public Class InternetUser Public username as string End Class -- Ok so now I need my specific application "Blah" to inherit from these methods. My PROBLEM comes with this InternetUser type. My new appliation is extending this InternetUser type as well, so this MustOverride method AddUser needs to be changed to accept a "BlahUser" now. Since a BlahUser IS A InternetUser, I would think I can do this somehow. Public Class BlahUser : Inherits InternetUser End Class Public Class BlahUserManager : Inherits UserManager 'my problem is what can I do when it comes to overriding the Sub "AddUser", since I'm now using BlahUser's, I'm getting compiler errors Public Overrides Sub AddUser(usr as BlahUser) '<-- getting a compiler error here, since signature doesn't match parent. End Sub End Class How can I successfully override this sub, but change the signature of the sub? I'd really like to have either an Interface or MustOverride Subs/Methods. I know I can use shadows, but that really seems like a cop out way of doing things, and I'm throwing out polymorphism when I do it. I hope this is clear enough!, perhaps I'm just way off the mark here about how to do something like this, but I would almost think this should be able to be done. Thanks for any help! --Michael
Another Option would be to use an Inteface
That way its complete abstract and you can put in whatever you want...
-CJ
"Raterus" <mo*********@su retar.reverse> wrote in message
news:uY******** ******@TK2MSFTN GP14.phx.gbl...
I had even thought to do that, but never went as far as to try, thanks!
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
news:Oy******** ******@TK2MSFTN GP12.phx.gbl... Tye Overloads instead of overrides as they are different types ( BlahUsr
and InternetUser )
-- OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y() For i As Int32 = 0 To ch.Length - 1 ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1) Next Process.Start(" mailto:" & New String(ch)) --
"Raterus" <mo*********@su retar.reverse> wrote in message news:OI******** ******@tk2msftn gp13.phx.gbl... I've got a good question about object-oriented programming, I hope I can explain it well enough. I'm creating a UserManager, which I'm going to inherit from so different applications can share common methods.
Public MustInherit Class UserManager Public MustOverride Sub AddUser(usr as InternetUser) End Class
Public Class InternetUser Public username as string End Class
--
Ok so now I need my specific application "Blah" to inherit from these methods. My PROBLEM comes with this InternetUser type. My new appliation is extending this InternetUser type as well, so this MustOverride method AddUser needs to be changed to accept a "BlahUser" now. Since a BlahUser
IS A InternetUser, I would think I can do this somehow.
Public Class BlahUser : Inherits InternetUser
End Class
Public Class BlahUserManager : Inherits UserManager 'my problem is what can I do when it comes to overriding the Sub "AddUser", since I'm now using BlahUser's, I'm getting compiler errors
Public Overrides Sub AddUser(usr as BlahUser) '<-- getting a compiler error here, since signature doesn't match parent.
End Sub End Class
How can I successfully override this sub, but change the signature of the sub? I'd really like to have either an Interface or MustOverride Subs/Methods. I know I can use shadows, but that really seems like a cop out way of doing things, and I'm throwing out polymorphism when I do it.
I hope this is clear enough!, perhaps I'm just way off the mark here about how to do something like this, but I would almost think this should be
able to be done.
Thanks for any help! --Michael
Can you give me some more details on implementing this? I know how to write an interface, but I'm getting confused when it comes to implementing and interface that has different return types than the interface.
Thanks,
"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. Another Option would be to use an Inteface That way its complete abstract and you can put in whatever you want... -CJ "Raterus" <mo*********@su retar.reverse> wrote in message news:uY******** ******@TK2MSFTN GP14.phx.gbl... I had even thought to do that, but never went as far as to try, thanks! "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message news:Oy******** ******@TK2MSFTN GP12.phx.gbl... Tye Overloads instead of overrides as they are different types ( BlahUsr and InternetUser )
-- OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y() For i As Int32 = 0 To ch.Length - 1 ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1) Next Process.Start(" mailto:" & New String(ch)) --
"Raterus" <mo*********@su retar.reverse> wrote in message news:OI******** ******@tk2msftn gp13.phx.gbl... I've got a good question about object-oriented programming, I hope I can explain it well enough. I'm creating a UserManager, which I'm going to inherit from so different applications can share common methods.
Public MustInherit Class UserManager Public MustOverride Sub AddUser(usr as InternetUser) End Class
Public Class InternetUser Public username as string End Class
--
Ok so now I need my specific application "Blah" to inherit from these methods. My PROBLEM comes with this InternetUser type. My new appliation is extending this InternetUser type as well, so this MustOverride method AddUser needs to be changed to accept a "BlahUser" now. Since a BlahUser IS A InternetUser, I would think I can do this somehow.
Public Class BlahUser : Inherits InternetUser
End Class
Public Class BlahUserManager : Inherits UserManager 'my problem is what can I do when it comes to overriding the Sub "AddUser", since I'm now using BlahUser's, I'm getting compiler errors
Public Overrides Sub AddUser(usr as BlahUser) '<-- getting a compiler error here, since signature doesn't match parent.
End Sub End Class
How can I successfully override this sub, but change the signature of the sub? I'd really like to have either an Interface or MustOverride Subs/Methods. I know I can use shadows, but that really seems like a cop out way of doing things, and I'm throwing out polymorphism when I do it.
I hope this is clear enough!, perhaps I'm just way off the mark here about how to do something like this, but I would almost think this should be able to be done.
Thanks for any help! --Michael
It's really not much different than what your doing now... except you define
your interface such that
Public Interface MySampleInterfa ce
... Methods , Properties, Events
End Interface
Public Class MyInternetUser
Implements MySampleInterfa ce
.blah
End class
Finally the kicker
Public MustInherit Class UserManager
Public Overridable Sub AddUser(IUser as MySampleInterfa ce)
end class
Forgive the poor naming conventions used, I'm just typing it in, not
actually testing it as I go...
You could do the usermanager as an interface as well if you so desired to
give it even more abstraction.
Such that
Public Interface IUserManager
Sub AddUser (IUser as MySampleInterfa ce)
End Interface
"Raterus" <mo*********@su retar.reverse> wrote in message
news:uY******** ******@TK2MSFTN GP10.phx.gbl...
Can you give me some more details on implementing this? I know how to write
an interface, but I'm getting confused when it comes to implementing and
interface that has different return types than the interface.
Thanks,
"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. Another Option would be to use an Inteface
That way its complete abstract and you can put in whatever you want...
-CJ
"Raterus" <mo*********@su retar.reverse> wrote in message news:uY******** ******@TK2MSFTN GP14.phx.gbl... I had even thought to do that, but never went as far as to try, thanks!
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in
message news:Oy******** ******@TK2MSFTN GP12.phx.gbl... Tye Overloads instead of overrides as they are different types ( BlahUsr and InternetUser )
-- OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y() For i As Int32 = 0 To ch.Length - 1 ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1) Next Process.Start(" mailto:" & New String(ch)) --
"Raterus" <mo*********@su retar.reverse> wrote in message news:OI******** ******@tk2msftn gp13.phx.gbl... I've got a good question about object-oriented programming, I hope I can explain it well enough. I'm creating a UserManager, which I'm going to inherit from so different applications can share common methods.
Public MustInherit Class UserManager Public MustOverride Sub AddUser(usr as InternetUser) End Class
Public Class InternetUser Public username as string End Class
--
Ok so now I need my specific application "Blah" to inherit from these methods. My PROBLEM comes with this InternetUser type. My new
appliation is extending this InternetUser type as well, so this MustOverride method AddUser needs to be changed to accept a "BlahUser" now. Since a
BlahUser IS A InternetUser, I would think I can do this somehow.
Public Class BlahUser : Inherits InternetUser
End Class
Public Class BlahUserManager : Inherits UserManager 'my problem is what can I do when it comes to overriding the Sub "AddUser", since I'm now using BlahUser's, I'm getting compiler errors
Public Overrides Sub AddUser(usr as BlahUser) '<-- getting a compiler error here, since signature doesn't match parent.
End Sub End Class
How can I successfully override this sub, but change the signature of
the sub? I'd really like to have either an Interface or MustOverride Subs/Methods. I know I can use shadows, but that really seems like a
cop out way of doing things, and I'm throwing out polymorphism when I do it.
I hope this is clear enough!, perhaps I'm just way off the mark here
about how to do something like this, but I would almost think this should be able to be done.
Thanks for any help! --Michael
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Shawn Casey |
last post by:
Consider the following code:
interface IBase
{
virtual void BaseFunction() = 0;
};
interface IDerived : public IBase
{
virtual void DerivedFunction() = 0;
|
by: Steve Jorgensen |
last post by:
The classing Visual Basic and VBA support for polymorphism, let's face it, is
a bit on the weak side, and built-in support for inheritance is non-existent.
This little essay is about some patterns I've ended up using successfully for
certain kinds of inheritance and polymorphism, and some that have not worked
out so well.
Let's start with obvious things that turn out not to work well:
1. Use interface classes and "Implements" for...
|
by: Matthew Louden |
last post by:
I want to know why C# doesnt support multiple inheritance? But why we can
inherit multiple interfaces instead? I know this is the rule, but I dont
understand why. Can anyone give me some concrete examples?
|
by: Binod Nair |
last post by:
Hi All,
Can somebody tell me what I am doing wrong.
I have a Base Abstract Class
Public MustInherit Class BaseRequestHandler : Inherits System.Web.UI.Page
Protected Overridable Sub Page_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
|
by: Oenone |
last post by:
I could use a little advice to help prevent me making a possible mess of a
project. :)
In VB6, I once created a project that exposed a public interface class. I
then Implemented this in various plug-in DLLs so that I could early-bind to
the plug-ins by declaring objects of the interface class type.
This worked fine, until one day I found that I needed to add a new method to
the interface class. Of course, everything broke immediately...
| |
by: gwolinsky |
last post by:
I originally posted this in the WindowsForms group but that may not
have been the best place to post it. So, I am reposting here.
--------------------------------------
I am trying to implement the new INotifyPropertyChanged interface in my
custom business object. The problem I'm having is with the inheritance
model.
I have a base object called "Person". The object "Employee" inherits
|
by: Ray Cassick \(Home\) |
last post by:
Since I got such good feedback from the Xml comments question I will ask
this of the group as well.
Is VS.NET 2005 handling the visual inheritance problems centered around
controls and forms that are decorated with MustInherit any better than 2003
did?
I am getting really tired of having to do the good old '#If DEBUG Then'
workaround just to get by this.
|
by: Eric |
last post by:
Hi,
I am kind of new to OO and I have the following problem :
I have a class containing a huge list of functions for accessing an SQL
database.
Public Class Transaction
#region "Client"
Public function GetClientInfos() as Dataset ...
Public sub InsertClientInfos() ...
|
by: Simon Woods |
last post by:
Hi
I'm just working through (and learning) the standard GoF Design Pattern and
the example of the Bridge pattern on
http://www.dofactory.com/Patterns/PatternBridge.aspx#_self2
I notice at the heart of the real world example is an abstract class
MustInherit Class DataObject
Public MustOverride Sub NextRecord()
|
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...
|
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...
| |
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...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |