R
Raterus
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
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