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

Can I allow varying types on a MustOverride

I am looking to have a base class which provides that all inherited
classes MUST have some property, but that they can each define it as
whatever type they want. So maybe three class inherit from the base
class, each MUST have a [Type] property, but one defines it as
OracleType, one as SqlType and one as DB2Type, for example.

I know i can just declare it as Object, and then have the classes each
do typechecks on value assignment, but this is late-bound. I would like
some way to implement this so that the type-specificity of each class is
early-bound, allowing for compile time type checking.

Is this possible?

TIA-
- Aaron.

================================================== ============

This is what i want (generic code)...

Class BaseClass
Public MustOverride Property Type

... other class code ...
End Class

Class OraClass
Inherits BaseClass

Public Overrides Property Type As OracleType

... other class code ...
End Class

Class SqlClass
Inherits BaseClass

Public Overrides Property Type As SqlType

... other class code ...
End Class

Jul 21 '05 #1
1 1491
The only way I know of to do this is via polymorphism, if all the
types support a common interface. For example:

Class BaseClass
Public MustOverride Property Type As INativeDBType

... other class code ...
End Class

If OracleType and SqlType both implement interface INativeDBType, your
derived classes should work as declared below. Replace "INativeDBType"
with whatever the common interface is, if there is one. If not, I
don't think this can be done early-bound.


Eidolon <aa****@KILLSPAM.yahoo.com> wrote in message news:<em**************@TK2MSFTNGP09.phx.gbl>...
I am looking to have a base class which provides that all inherited
classes MUST have some property, but that they can each define it as
whatever type they want. So maybe three class inherit from the base
class, each MUST have a [Type] property, but one defines it as
OracleType, one as SqlType and one as DB2Type, for example.

I know i can just declare it as Object, and then have the classes each
do typechecks on value assignment, but this is late-bound. I would like
some way to implement this so that the type-specificity of each class is
early-bound, allowing for compile time type checking.

Is this possible?

TIA-
- Aaron.

================================================== ============

This is what i want (generic code)...

Class BaseClass
Public MustOverride Property Type

... other class code ...
End Class

Class OraClass
Inherits BaseClass

Public Overrides Property Type As OracleType

... other class code ...
End Class

Class SqlClass
Inherits BaseClass

Public Overrides Property Type As SqlType

... other class code ...
End Class

Jul 21 '05 #2

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

Similar topics

1
by: fripper | last post by:
I have had some experience with VB .Net but I am having difficulty coming to grips with how to set up a subroutine to accept varying classes for its arguments. An example will help to explain. I...
0
by: Mike Leahy | last post by:
Okay.I'm following the documentation that came with the PostgreSQL source code (located in /usr/doc/postgresql-7.3.4-2/html/arrays.hmtl in my cygwin root). I created have a table with a varchar...
2
by: Michael . | last post by:
I had an error before involving a temporary table, and that has been taken care of... The last message I wrote where it seemed to have needed it after I added it was because of different...
2
by: Dave Wurtz | last post by:
All, Is there a way to force a derived class to contain an event. I have done this with methods (i.e. Protected MustOverride Sub Test), but can I do something similar with an event (Protected...
8
by: Dave Wurtz | last post by:
All, Is there a way to force a derived class to contain an event. I have done this with methods (i.e. Protected MustOverride Sub Test), but can I do something similar with an event (Protected...
7
by: Iain Mcleod | last post by:
Hi This must be an often encountered problem. I want to declare an abstract class or an interface with nothing but several static constants so that I can use polymorphism when I call each of them...
7
by: Raterus | last post by:
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...
1
by: Eidolon | last post by:
I am looking to have a base class which provides that all inherited classes MUST have some property, but that they can each define it as whatever type they want. So maybe three class inherit from...
4
by: Confused Newbie | last post by:
I'm converting an app written in VB 2003 to 2005 and need advice for how to deal with this situation: The app has a number of "manager" classes that handle the data access. They all have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...

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.