R
Richard Tappenden
Hi!
I'm struggling a bit with Polymorphism in vb.net. There is something I know
I can do in C++, but I cannot seem to do it in vb.net (or c# for that
matter).
Basically, I have an abstract base class that deals with adding, deleting,
editing another class.
I have written an implementation of that class, and also a derived version
of the 'managed' class - so effectively my derived version manages a
specialised version of whatever the base one does. However, the compiler
complains that I havent implemented the MustInherit methods...
To explain a bit better...
Public Class CMessage
' This is the "managed" class
Public MustInherit Class CMessageManager
' This is the abstract base class
Public MustOverride Function MessageReceived (ByRef objMessage As
CMessage) As Boolean
Public Class CEmail Inherits CMessage
' Derived version
Public Class CEmailMessageManager Inherits CMessageManager
' Implemented version - want it to deal with emails
Public MustOverride Function MessageReceived (ByRef objMessage As CEmail)
As Boolean
' Pass in an email and deal with it
This concept is supported by C++ - it must be possible to do it in .NET, but
I really dont know how.
Any help would be greatly appreciated!
I'm struggling a bit with Polymorphism in vb.net. There is something I know
I can do in C++, but I cannot seem to do it in vb.net (or c# for that
matter).
Basically, I have an abstract base class that deals with adding, deleting,
editing another class.
I have written an implementation of that class, and also a derived version
of the 'managed' class - so effectively my derived version manages a
specialised version of whatever the base one does. However, the compiler
complains that I havent implemented the MustInherit methods...
To explain a bit better...
Public Class CMessage
' This is the "managed" class
Public MustInherit Class CMessageManager
' This is the abstract base class
Public MustOverride Function MessageReceived (ByRef objMessage As
CMessage) As Boolean
Public Class CEmail Inherits CMessage
' Derived version
Public Class CEmailMessageManager Inherits CMessageManager
' Implemented version - want it to deal with emails
Public MustOverride Function MessageReceived (ByRef objMessage As CEmail)
As Boolean
' Pass in an email and deal with it
This concept is supported by C++ - it must be possible to do it in .NET, but
I really dont know how.
Any help would be greatly appreciated!