Results 1 to 13 of 13

Thread: Inheritance

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    89

    Inheritance

    Is it possible, in VB.NET, to do multiple inheritance ? Like in C# :

    [C#]
    class Class_A { }
    class Class_B { }

    class Class_C: Class_A, Class_B { }


    I've try in VB, but isn't working. How VB.NET couldn't support multiple inheritance if C# can ???

    Thanks in advance guys...
    BlahDoS . :P

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    C# doesnt support multiple inheritance either. You are probably confusing inheritance and interfaces.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    89
    DAMN IT, WHY !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    BlahDoS . :P

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    you can always have class B inherit class A and class C inherit Class B.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5
    Lively Member
    Join Date
    Jul 2002
    Location
    Planet Earth
    Posts
    99
    Okay only on my first couple of weeks of vb.net here but it appears inheritance works down in a tree format

    e.g

    Vehicle

    Car inherits from Vehicle

    Holden inherits from Car and from Vehicle...
    Ford inherits from Car and from Vehicle...

    If this is wrong can some one point it out before l get too far into this project.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    89
    But if I want to create a SuperVehicule thats include both Car and Plane inherited class, how would I do that ???

    class Vehicule {...}

    class Car : Vehicule {...}
    class Plane : Vehicule {...}


    class SuperVehicule : ??????? {...}
    BlahDoS . :P

  7. #7
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Car Inherits vehicle
    Plane inherits car
    supervehicle inherits plane
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  8. #8
    Lively Member
    Join Date
    Jul 2002
    Location
    Planet Earth
    Posts
    99
    And it's one line of code. At level two of our class hierarchy, and it's working a treat. Thanks MS for this long anticipated feature.

    A couple of the C++ guys at the office had a look, and were very impressed by the usage of inheritance in vb.net. Of course they still claim C++ owns vb, but what do you expect. Monday might just show them C#. hehehehehehe.

    As stated, it appears to be a tree structure which IMO is the logical way to organise it. So in your case it would be logical to declare

    Vehicle

    Car inherits from Vehicle.

    Plane inherits from Vehicle.

    SuperVehicle inherits from Car and Plane, and thus vehicle.

    The major headache l'm having is deciding at what level a property should be declared. It really takes some nutting out whether classes should all have a property for say model (hence pop it into the top class and inherit it), or make it specific to a class... it's actually forcing us to spend more time on design. Which is a good thing.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    89
    Actually, we can't do that in VB.NET. Its impossible to inherits a class from more than one class.

    so

    class Blah : Car, Plane -> error.

    And Cander, Its can't be done like that because its so ugly !!! a plane is not a Car ...
    BlahDoS . :P

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    89
    BTW what is IMO ??? and why does the C++ claims that inheritance in VB is great, ITS AWFUL.

    try that.

    my class MUST inherits two class already code in VB.NET
    the 2 classes are :
    - system.web.ui.usercontrol
    - system.web.ui.webcontrols.dropdownlist
    BlahDoS . :P

  11. #11
    Lively Member
    Join Date
    Jul 2002
    Location
    Planet Earth
    Posts
    99
    Originally posted by BlahDoS
    BTW what is IMO ??? and why does the C++ claims that inheritance in VB is great, ITS AWFUL.

    try that.

    my class MUST inherits two class already code in VB.NET
    the 2 classes are :
    - system.web.ui.usercontrol
    - system.web.ui.webcontrols.dropdownlist
    IMO = In My Opinion.

    I was talking about a couple of people in our office who are C++ heads, but grudingly liked inheritance as used in vb.net. As stated they still claim C++ ownz vb, or some such.

    So the doco l'm reading on class inheritance is incorrect Damn, time to go back to the specs then. As stated only really have got into vb.net over the last couple of weeks, and am relying on a few documents people have prepared. Time to go get some books methinks.

    That inheritance tree thing is going to be a problem for us. Designed it down to four levels thinking inheritance would resolve from Super class to individual class as in

    Super Class

    Model Class inherits from SC

    Brand inherits from Model hence SC

    Product inherits from Brand hence Model hence SC.

    Guess Rome wasn't built in a day...

  12. #12
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Originally posted by BlahDoS
    my class MUST inherits two class already code in VB.NET
    the 2 classes are :
    - system.web.ui.usercontrol
    - system.web.ui.webcontrols.dropdownlist
    Inherits or Imports? There is a big difference.

  13. #13
    Lively Member
    Join Date
    Jul 2002
    Location
    Planet Earth
    Posts
    99
    Originally posted by Edneeis


    Inherits or Imports? There is a big difference.
    See now you've lost me.

    Using Imports for framework components. Can you also import a class struture, and if so does this have some advantage over how l'm doing it via reference...

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