|
-
Mar 15th, 2004, 04:02 PM
#1
Thread Starter
Frenzied Member
inheriting more than once [RESOLVED]
I know you can't inherit but once in a class. what's a workaround to include several other classes into one class? I have some classes that work great by themselves and I need those same exact properties to be included in an entirely different class though.
other than re-writing the properties and methods, IS there a better way?
Last edited by Andy; Mar 25th, 2004 at 10:00 PM.
-
Mar 15th, 2004, 04:41 PM
#2
Frenzied Member
You can create many classes (as well as nested classes) within a single class (.vb) file.
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Mar 15th, 2004, 04:54 PM
#3
Thread Starter
Frenzied Member
where do I find info on nested classes? I've never heard of that one
-
Mar 15th, 2004, 05:58 PM
#4
yay gay
Nested classes are just classes inside classes. They dont provide any extra functionalitty.
\m/  \m/
-
Mar 15th, 2004, 07:15 PM
#5
PowerPoster
Hi,
"where do I find info on nested classes? I've never heard of that one "
Whilst "Nested" or "Sub Classes" does describe the practical relationship, the official term is "Class Hierarchies". Check it out in MSDN Help.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Mar 16th, 2004, 03:53 PM
#6
Thread Starter
Frenzied Member
I will check that out. But I'm thinking that's not going to help in my situation. I was thinking of creating classes that contained itty bitty pieces of data and combine ALL of them to create one gigantic, useful class:
VB Code:
public class whatever
inherits oneClass
inherits anotherClass
inherits yetAnotherClass
'This way, the "Whatever" class won't have to be duplicating the other classes.
Unfortunately, you can't inherit more than once. Why is that?
-
Mar 16th, 2004, 04:48 PM
#7
PowerPoster
Hi,
"Unfortunately, you can't inherit more than once. Why is that?"
The responses have all misunderstood your meaning. We thought you were saying that you could not inherit more than once. What you mean is that you cannot inherit from more than one class. That is the present situation with .NET. You COULD inherit from multiple classes in C++ but not in any of the .NET languages. I thought I read in a previous post that this will change in a future version.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Mar 16th, 2004, 05:21 PM
#8
Frenzied Member
Each class would just inherit from its parent, which in turn would inherit from its parent, etc...
VB Code:
Public Class1 [color=red](Base Class)[/color]
'some code
End Class
Public Class2
Inherits Class1
'Inherits all functionality of Class1
End Class
Public Class3
Inherits Class2
'Inherits all functionality from Class2 AND Class1
End Class
Public Class4
Inherits Class3
'Inherits all functionality from Class3 AND Class2 AND Class1
End Class
VB Code:
Public Class MyClass
Inherits Class4
'Inherits functionality from ALL 4 Classes
End Class
Last edited by Memnoch1207; Mar 16th, 2004 at 05:25 PM.
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Mar 16th, 2004, 08:10 PM
#9
PowerPoster
Hi Phantom,
Thinking about it, you could possibly achieve what you want with a little effort.
Say you have fcls1, fcls2, fcls3, each one designed as a base class form, inheriting from System.Windows.Forms.Form.
Say you then decided you wanted to combine all their objects etc.
How about amending the inheritance statement in fcls2 to
Inherits fcls1.
Then change the inheritance statement in fcls3 to
Inherits fcls2
If at any time you wanted to revert to the original form states, alter the inheritance statments back to
System.Windows.Forms.Form
I emphasise that I have not tried this!!!!
EDIT It looks as if you can't change them back to
System.Windows.Forms.Form
because they retain their acquired objects.
Last edited by taxes; Mar 16th, 2004 at 08:15 PM.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Mar 17th, 2004, 08:59 AM
#10
Thread Starter
Frenzied Member
interesting, interesting...I'll give those suggestions a go around..or as my project leader likes to say" Jack with it for a while"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|