Results 1 to 10 of 10

Thread: inheriting more than once [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    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.

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    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

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    where do I find info on nested classes? I've never heard of that one

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Nested classes are just classes inside classes. They dont provide any extra functionalitty.
    \m/\m/

  5. #5
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    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:
    1. public class whatever
    2.  
    3. inherits oneClass
    4. inherits anotherClass
    5. inherits yetAnotherClass
    6.  
    7. '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?

  7. #7
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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.

  8. #8
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Each class would just inherit from its parent, which in turn would inherit from its parent, etc...
    VB Code:
    1. Public Class1 [color=red](Base Class)[/color]
    2.    'some code
    3. End Class
    4.  
    5. Public Class2
    6.    Inherits Class1
    7.    
    8.    'Inherits all functionality of Class1
    9. End Class
    10.  
    11. Public Class3
    12.    Inherits Class2
    13.  
    14.    'Inherits all functionality from Class2 AND Class1
    15. End Class
    16.  
    17. Public Class4
    18.    Inherits Class3
    19.  
    20.    'Inherits all functionality from Class3 AND Class2 AND Class1
    21. End Class

    VB Code:
    1. Public Class MyClass
    2.    Inherits Class4
    3.  
    4.    'Inherits functionality from ALL 4 Classes
    5. 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

  9. #9
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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.

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    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
  •  



Click Here to Expand Forum to Full Width