|
-
Jul 18th, 2002, 01:22 PM
#1
Thread Starter
Lively Member
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...
-
Jul 18th, 2002, 01:48 PM
#2
C# doesnt support multiple inheritance either. You are probably confusing inheritance and interfaces.
-
Jul 18th, 2002, 02:46 PM
#3
Thread Starter
Lively Member
DAMN IT, WHY !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
Jul 18th, 2002, 03:00 PM
#4
you can always have class B inherit class A and class C inherit Class B.
-
Jul 25th, 2002, 08:22 PM
#5
Lively Member
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.
-
Jul 26th, 2002, 10:50 AM
#6
Thread Starter
Lively Member
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 : ??????? {...}
-
Jul 26th, 2002, 11:00 AM
#7
Car Inherits vehicle
Plane inherits car
supervehicle inherits plane
-
Jul 26th, 2002, 01:08 PM
#8
Lively Member
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.
-
Jul 26th, 2002, 01:27 PM
#9
Thread Starter
Lively Member
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 ...
-
Jul 26th, 2002, 01:31 PM
#10
Thread Starter
Lively Member
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
-
Jul 26th, 2002, 02:17 PM
#11
Lively Member
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...
-
Jul 26th, 2002, 03:07 PM
#12
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.
-
Jul 26th, 2002, 03:29 PM
#13
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|