By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,589 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,589 IT Pros & Developers. It's quick & easy.

Multi Inherence

P: n/a
Is there a way to overpass the impossibility of VN.NET to accept the multi
heritage, that is to allow a class to inherit from TWO mother classes ?

--
Bernard Bourée
be*****@bouree.net
Nov 21 '05 #1
Share this Question
Share on Google+
27 Replies


P: n/a
"Bernard Bourée" <be*****@bouree.net> schrieb:
Is there a way to overpass the impossibility of VN.NET to accept the multi
heritage, that is to allow a class to inherit from TWO mother classes ?


Not directly, but you can go the delegation way that was used in VB6 to
archieve implementation inheritance.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #2

P: n/a
No.

You will have to achieve what you want with inheriting from 1 and using
interfaces. Or having your class contain an instance of another as a
private member, and forwarding method calls to that object (if that can work
for your situation).

"Bernard Bourée" <be*****@bouree.net> wrote in message
news:eF*************@TK2MSFTNGP11.phx.gbl...
Is there a way to overpass the impossibility of VN.NET to accept the multi
heritage, that is to allow a class to inherit from TWO mother classes ?

--
Bernard Bourée
be*****@bouree.net

Nov 21 '05 #3

P: n/a
>> Is there a way to overpass the impossibility of VN.NET to accept the
multi
heritage, that is to allow a class to inherit from TWO mother classes ?


Not directly, but you can go the delegation way that was used in VB6 to
archieve implementation inheritance.


Here's a bizarre idea from left field... C++ can do multiple inheritance.
Could he do it via C++ / Managed Extensions and then use it from VB?
--
Peace & happy computing,

Mike Labosh, MCSD
"I have no choice but to believe in free will."
Nov 21 '05 #4

P: n/a
JD
C++ can do multiple inheritance, Managed C++ cannot.
"Mike Labosh" <ml*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Is there a way to overpass the impossibility of VN.NET to accept the
multi
heritage, that is to allow a class to inherit from TWO mother classes ?


Not directly, but you can go the delegation way that was used in VB6 to
archieve implementation inheritance.


Here's a bizarre idea from left field... C++ can do multiple inheritance.
Could he do it via C++ / Managed Extensions and then use it from VB?
--
Peace & happy computing,

Mike Labosh, MCSD
"I have no choice but to believe in free will."

Nov 21 '05 #5

P: n/a
Herfried

Can you tell me more about delegation or some links ?

Thanks
--
Bernard Bourée
be*****@bouree.net
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> a écrit dans le
message de news:eO**************@TK2MSFTNGP09.phx.gbl...
"Bernard Bourée" <be*****@bouree.net> schrieb:
Is there a way to overpass the impossibility of VN.NET to accept the multi heritage, that is to allow a class to inherit from TWO mother classes ?


Not directly, but you can go the delegation way that was used in VB6 to
archieve implementation inheritance.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #6

P: n/a
Marina

Do you know where I can find an example?

Thanks

--
Bernard Bourée
be*****@bouree.net
"Marina" <so*****@nospam.com> a écrit dans le message de
news:O9**************@TK2MSFTNGP10.phx.gbl...
No.

You will have to achieve what you want with inheriting from 1 and using
interfaces. Or having your class contain an instance of another as a
private member, and forwarding method calls to that object (if that can work for your situation).

"Bernard Bourée" <be*****@bouree.net> wrote in message
news:eF*************@TK2MSFTNGP11.phx.gbl...
Is there a way to overpass the impossibility of VN.NET to accept the multi heritage, that is to allow a class to inherit from TWO mother classes ?

--
Bernard Bourée
be*****@bouree.net


Nov 21 '05 #7

P: n/a

"Bernard Bourée" <be*****@bouree.net> wrote
Is there a way to overpass the impossibility of VN.NET to accept the multi
heritage, that is to allow a class to inherit from TWO mother classes ?


If there was a often used need for multiple inheritance, then MS would have
probably found a way to include it. Evidently they decided there wasn't
an absolute need that would be common enough for the functionality.

Perhaps if you describe what you want to do, someone can explain how
to do that within the confines of the language you are using....

LFS

Nov 21 '05 #8

P: n/a
Bernard,
While Microsoft's .NET programming languages do not provide
multiple-inheritence they do provide ways to implement multiple-inheritance
like behavior.

There are other .NET programming languages that do support
multiple-inheritance:

Haskell.NET (HUGS98) is Haskell as a .NET programming language that allows
multiple-inheritance.

Eifel for .NET is another .NET programming language that allows
multiple-inhieritance:

http://msdn.microsoft.com/library/de...pdc_eiffel.asp
--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
"Bernard Bourée" <be*****@bouree.net> wrote in message
news:eF*************@TK2MSFTNGP11.phx.gbl...
Is there a way to overpass the impossibility of VN.NET to accept the multi
heritage, that is to allow a class to inherit from TWO mother classes ?

--
Bernard Bourée
be*****@bouree.net

Nov 21 '05 #9

P: n/a
"Bernard Bourée" <be*****@bouree.net> schrieb:
Can you tell me more about delegation or some links ?


Sample (untested):

\\\
Public Interface IB
Sub Goo()
End Interface

Public Interface IC
Sub Foo()
End Interface

Public Class A
Implements IB, IC

Private m_IB As IB
Private m_IC As IC

Public Sub New(ByVal IBImpl As IB, ByVal ICImpl As IC)
m_IB = IBImpl
m_IC = ICImpl
End Sub

Public Sub Goo() Implements IB.Goo
m_IB.Goo()
End Sub

Public Sub Foo() Implements IC.Foo
m_IC.Foo()
End Sub
End Class

Public Class B
Implements IB

...
End Class

Public Class C
Implements IC

...
End Class
..
..
..
Dim f As New A(New B(), New C())
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #10

P: n/a
Well if I try to make it simple

I have one class named FLUID which contains various properties like
Pressure
Temp
FlowRate

An other class named DROP which contains properties like
Diameter
Temp
Pressure

And a last one called SECTION which should contains the properties of FLUID,
DROP plus some others.
So the solution I have now is to make a copy of the FLUID's properties
inside SECTION

But If I have to change the properties of FLUID I have to remind to do it in
both places.

Thank for your help

--
Bernard Bourée
be*****@bouree.net
"Larry Serflaten" <se*******@usinternet.com> a écrit dans le message de
news:%2****************@tk2msftngp13.phx.gbl...

"Bernard Bourée" <be*****@bouree.net> wrote
Is there a way to overpass the impossibility of VN.NET to accept the multi heritage, that is to allow a class to inherit from TWO mother classes ?
If there was a often used need for multiple inheritance, then MS would

have probably found a way to include it. Evidently they decided there wasn't
an absolute need that would be common enough for the functionality.

Perhaps if you describe what you want to do, someone can explain how
to do that within the confines of the language you are using....

LFS

Nov 21 '05 #11

P: n/a
Bernard,
In addition to the other comments, you could use one or more Interfaces:

Something like:
Public Interface IFluid
Property Pressure() As Integer
Property Temp() As Integer
Property FlowRate() As Integer
End Interface

Public Class Fluid
Implements IFluid

Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer

Public Property FlowRate() As Integer Implements IFluid.FlowRate
Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property

Public Property Pressure() As Integer Implements IFluid.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IFluid.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

End Class

Public Interface IDrop
Property Diameter() As Integer
Property Temp() As Integer
Property Pressure() As Integer
End Interface

Public Class Drop
Implements IDrop

Private m_diameter As Integer
Private m_pressure As Integer
Private m_temp As Integer

Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property

Public Property Pressure() As Integer Implements IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IDrop.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

End Class

Public Interface ISection
Inherits IFluid
Inherits IDrop
End Interface

Public Class Section
Implements ISection

Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer
Private m_diameter As Integer

Public Property FlowRate() As Integer Implements IFluid.FlowRate
Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property

Public Property Pressure() As Integer Implements IFluid.Pressure,
IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IFluid.Temp, IDrop.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property

End Class

Then rather then define your parameters as the class, you would define them
as the Interface.

For Example:

Public Shared Sub ProcessFluid(ByVal aFluid As IFluid)
Debug.WriteLine(CObj(aFluid).GetType().Name)
Debug.Indent()
Debug.WriteLine(aFluid.Pressure, "Fluid.Pressure")
Debug.WriteLine(aFluid.Temp, "Fluid.Temp")
Debug.WriteLine(aFluid.FlowRate, "Fluid.FlowRate")
Debug.Unindent()
End Sub

Public Shared Sub ProcessDrop(ByVal aDrop As IDrop)
Debug.WriteLine(CObj(aFluid).GetType().Name)
Debug.Indent()
Debug.WriteLine(aDrop.Diameter, "Drop.Diameter")
Debug.WriteLine(aDrop.Temp, "Drop.Diameter")
Debug.WriteLine(aDrop.Pressure, "Drop.Pressure")
Debug.Unindent()
End Sub
Public Shared Sub Main()
Dim aFluid As New Fluid
Dim aDrop As New Drop
Dim aSection As New Section
ProcessFluid(aFluid)
ProcessFluid(aSection)

ProcessDrop(aDrop)
ProcessDrop(aSection)
End Sub

Note you don't need to use three actual interface, you can get by with only
defining Fluid or Drop in terms on an interface, then Section could inherit
from the other & implement the interface. The key is to use the Interface
instead of the class when you want to accept a Section in addition to the
class... Section could also implement ISection by using delegation to actual
Fluid & Drop objects...

Hope this helps
Jay
"Bernard Bourée" <be*****@bouree.net> wrote in message
news:ek**************@TK2MSFTNGP15.phx.gbl...
Well if I try to make it simple

I have one class named FLUID which contains various properties like
Pressure
Temp
FlowRate

An other class named DROP which contains properties like
Diameter
Temp
Pressure

And a last one called SECTION which should contains the properties of
FLUID,
DROP plus some others.
So the solution I have now is to make a copy of the FLUID's properties
inside SECTION

But If I have to change the properties of FLUID I have to remind to do it
in
both places.

Thank for your help

--
Bernard Bourée
be*****@bouree.net
"Larry Serflaten" <se*******@usinternet.com> a écrit dans le message de
news:%2****************@tk2msftngp13.phx.gbl...

"Bernard Bourée" <be*****@bouree.net> wrote
> Is there a way to overpass the impossibility of VN.NET to accept the multi > heritage, that is to allow a class to inherit from TWO mother classes ?


If there was a often used need for multiple inheritance, then MS would

have
probably found a way to include it. Evidently they decided there wasn't
an absolute need that would be common enough for the functionality.

Perhaps if you describe what you want to do, someone can explain how
to do that within the confines of the language you are using....

LFS


Nov 21 '05 #12

P: n/a
> C++ can do multiple inheritance, Managed C++ cannot.

Interesting --- the single inheritance thing is a "feature" of the CLR then?
--
Peace & happy computing,

Mike Labosh, MCSD
"I have no choice but to believe in free will."
Nov 21 '05 #13

P: n/a
Mike... True. But only if you mean implementation inheritance. The CLR
supports single inheritance of implementation and multiple inheritance
of
interfaces. In C#:

http://www.geocities.com/jeff_louie/OOP/oop9.htm
http://www.geocities.com/jeff_louie/OOP/oop16.htm

Regards,
Jeff
Interesting --- the single inheritance thing is a "feature" of the CLR

then?<
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #14

P: n/a
Just curious but if you can inheirit two interfaces and both have a property
or method that has the same name, how can you tell which one to use?

"Mike McIntyre" wrote:
Bernard,
While Microsoft's .NET programming languages do not provide
multiple-inheritence they do provide ways to implement multiple-inheritance
like behavior.

There are other .NET programming languages that do support
multiple-inheritance:

Haskell.NET (HUGS98) is Haskell as a .NET programming language that allows
multiple-inheritance.

Eifel for .NET is another .NET programming language that allows
multiple-inhieritance:

http://msdn.microsoft.com/library/de...pdc_eiffel.asp
--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
"Bernard Bourée" <be*****@bouree.net> wrote in message
news:eF*************@TK2MSFTNGP11.phx.gbl...
Is there a way to overpass the impossibility of VN.NET to accept the multi
heritage, that is to allow a class to inherit from TWO mother classes ?

--
Bernard Bourée
be*****@bouree.net


Nov 21 '05 #15

P: n/a

"Bernard Bourée" <be*****@bouree.net> wrote
Well if I try to make it simple

I have one class named FLUID which contains various properties like
Pressure
Temp
FlowRate

An other class named DROP which contains properties like
Diameter
Temp
Pressure

And a last one called SECTION which should contains the properties of FLUID,
DROP plus some others.
So the solution I have now is to make a copy of the FLUID's properties
inside SECTION

But If I have to change the properties of FLUID I have to remind to do it in
both places.


What you list does not appear to be inheritance, but rather polymorphism.
Inheritance is involved when class Drop "is a" class Fluid, which may or
may not be inherited, that part wasn't clear (cute pun, eh?). But then you
have a class Section that has the properties of Fluid, and the properties of
Drop, and the properties of some others. That involves polymorphism.

If that is what you want then you need to use interfaces, like Jay suggests.

HTH
LFS

Nov 21 '05 #16

P: n/a

"Dennis" <De****@discussions.microsoft.com> wrote
Just curious but if you can inheirit two interfaces and both have a property
or method that has the same name, how can you tell which one to use?


How can _who_ tell which one to use? The user or the class developer?

When you implement a member of an interface, the member is marked:

Private Sub SomeMethod() Implements MyInterface.MyMethod

Because both the interface and method are named, the CLR won't get confused....

LFS
Nov 21 '05 #17

P: n/a
consider this aircode:

Public Interface IFoo
Sub ThisMethod() 'same signature
End Interface

Public Interface IFee
Sub ThisMethod() 'same signature
End Interface

Public Class Fum Implements IFoo Implements IFee
Public Sub ThisMethod() Implements IFoo.ThisMethod
'stuff
End Sub
Public Sub ThisMethod() Implements IFee.ThisMethod
'other stuff
End Sub
End Class

I didn't try to compile it (it's late) but each method implementation is
clearly marked as to whose interface it's implementing.
--
Peace & happy computing,

Mike Labosh, MCSD
"I have no choice but to believe in free will."
Nov 21 '05 #18

P: n/a
Dennis,
My earlier sample shows one way of implementing two interfaces with the same
method.

Another way is to explicitly name the methods in the implementing class,
when I do this, I make the methods private:

Something like:

Public Class Section
Implements ISection

Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer
Private m_diameter As Integer

Public Property FlowRate() As Integer Implements IFluid.FlowRate
Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property

Public Property Pressure() As Integer Implements IFluid.Pressure,
IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

Private Property IFluid_Temp() As Integer Implements IDrop.Temp
Get
' do something unique for IFluid
Return m_temp
End Get
Set(ByVal value As Integer)
' do something unique for IFluid
m_temp = value
End Set
End Property

Private Property IDrop_Temp() As Integer IDrop.Temp
Get
' do something unique for IDrop
Return m_temp
End Get
Set(ByVal value As Integer)
' do something unique for IDrop
m_temp = value
End Set
End Property

Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property

End Class
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
Just curious but if you can inheirit two interfaces and both have a
property
or method that has the same name, how can you tell which one to use?

"Mike McIntyre" wrote:
Bernard,
While Microsoft's .NET programming languages do not provide
multiple-inheritence they do provide ways to implement
multiple-inheritance
like behavior.

There are other .NET programming languages that do support
multiple-inheritance:

Haskell.NET (HUGS98) is Haskell as a .NET programming language that
allows
multiple-inheritance.

Eifel for .NET is another .NET programming language that allows
multiple-inhieritance:

http://msdn.microsoft.com/library/de...pdc_eiffel.asp
--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
"Bernard Bourée" <be*****@bouree.net> wrote in message
news:eF*************@TK2MSFTNGP11.phx.gbl...
> Is there a way to overpass the impossibility of VN.NET to accept the
> multi
> heritage, that is to allow a class to inherit from TWO mother classes ?
>
> --
> Bernard Bourée
> be*****@bouree.net
>
>


Nov 21 '05 #19

P: n/a
Jay

Thank you so much for your help !!!

--
Bernard Bourée
be*****@bouree.net
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> a écrit dans le
message de news:Oh**************@tk2msftngp13.phx.gbl...
Bernard,
In addition to the other comments, you could use one or more Interfaces:

Something like:
Public Interface IFluid
Property Pressure() As Integer
Property Temp() As Integer
Property FlowRate() As Integer
End Interface

Public Class Fluid
Implements IFluid

Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer

Public Property FlowRate() As Integer Implements IFluid.FlowRate
Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property

Public Property Pressure() As Integer Implements IFluid.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IFluid.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

End Class

Public Interface IDrop
Property Diameter() As Integer
Property Temp() As Integer
Property Pressure() As Integer
End Interface

Public Class Drop
Implements IDrop

Private m_diameter As Integer
Private m_pressure As Integer
Private m_temp As Integer

Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property

Public Property Pressure() As Integer Implements IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IDrop.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

End Class

Public Interface ISection
Inherits IFluid
Inherits IDrop
End Interface

Public Class Section
Implements ISection

Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer
Private m_diameter As Integer

Public Property FlowRate() As Integer Implements IFluid.FlowRate
Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property

Public Property Pressure() As Integer Implements IFluid.Pressure,
IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IFluid.Temp, IDrop.Temp Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property

End Class

Then rather then define your parameters as the class, you would define them as the Interface.

For Example:

Public Shared Sub ProcessFluid(ByVal aFluid As IFluid)
Debug.WriteLine(CObj(aFluid).GetType().Name)
Debug.Indent()
Debug.WriteLine(aFluid.Pressure, "Fluid.Pressure")
Debug.WriteLine(aFluid.Temp, "Fluid.Temp")
Debug.WriteLine(aFluid.FlowRate, "Fluid.FlowRate")
Debug.Unindent()
End Sub

Public Shared Sub ProcessDrop(ByVal aDrop As IDrop)
Debug.WriteLine(CObj(aFluid).GetType().Name)
Debug.Indent()
Debug.WriteLine(aDrop.Diameter, "Drop.Diameter")
Debug.WriteLine(aDrop.Temp, "Drop.Diameter")
Debug.WriteLine(aDrop.Pressure, "Drop.Pressure")
Debug.Unindent()
End Sub
Public Shared Sub Main()
Dim aFluid As New Fluid
Dim aDrop As New Drop
Dim aSection As New Section
ProcessFluid(aFluid)
ProcessFluid(aSection)

ProcessDrop(aDrop)
ProcessDrop(aSection)
End Sub

Note you don't need to use three actual interface, you can get by with only defining Fluid or Drop in terms on an interface, then Section could inherit from the other & implement the interface. The key is to use the Interface
instead of the class when you want to accept a Section in addition to the
class... Section could also implement ISection by using delegation to actual Fluid & Drop objects...

Hope this helps
Jay
"Bernard Bourée" <be*****@bouree.net> wrote in message
news:ek**************@TK2MSFTNGP15.phx.gbl...
Well if I try to make it simple

I have one class named FLUID which contains various properties like
Pressure
Temp
FlowRate

An other class named DROP which contains properties like
Diameter
Temp
Pressure

And a last one called SECTION which should contains the properties of
FLUID,
DROP plus some others.
So the solution I have now is to make a copy of the FLUID's properties
inside SECTION

But If I have to change the properties of FLUID I have to remind to do it in
both places.

Thank for your help

--
Bernard Bourée
be*****@bouree.net
"Larry Serflaten" <se*******@usinternet.com> a écrit dans le message de
news:%2****************@tk2msftngp13.phx.gbl...

"Bernard Bourée" <be*****@bouree.net> wrote
> Is there a way to overpass the impossibility of VN.NET to accept the

multi
> heritage, that is to allow a class to inherit from TWO mother classes ?
If there was a often used need for multiple inheritance, then MS would

have
probably found a way to include it. Evidently they decided there wasn't an absolute need that would be common enough for the functionality.

Perhaps if you describe what you want to do, someone can explain how
to do that within the confines of the language you are using....

LFS



Nov 21 '05 #20

P: n/a
Bernard,
Is there a way to overpass the impossibility of VN.NET to accept the multi
heritage, that is to allow a class to inherit from TWO mother classes ?

I have always to be very carefully with this kind of texts because there is
some English language in it.

In my opinion is good design build on inheriting. Not on multi heritage.

And inheriting is build on the princible that a class can inherite from its
parent class.

And here comes the English language expect, for me can you never inherit
from two mothers. In natural life by instance Mothers can be an inherited
class from Human, where as well can be Fathers. There should never be a need
to instance as well from Fathers and Mothers because than you have to use
the class Human.

In my opinion you should avoid doing what you want that in your design, you
can make work arounds. However by instance inheriting from cars and from
mamals to create a new class is in my opinon always bad design, what you
should avoid as much as possible.

Just my thought reading this thread

Cor
Nov 21 '05 #21

P: n/a
Your note said that there are "other" .net languages that support multiple
inheiritances. I was asking how a class that inherited from two different
classes would know which property or method of the inheirited classes to call
if the two different classes happened to have a property or method with the
same name!

"Larry Serflaten" wrote:

"Dennis" <De****@discussions.microsoft.com> wrote
Just curious but if you can inheirit two interfaces and both have a property
or method that has the same name, how can you tell which one to use?


How can _who_ tell which one to use? The user or the class developer?

When you implement a member of an interface, the member is marked:

Private Sub SomeMethod() Implements MyInterface.MyMethod

Because both the interface and method are named, the CLR won't get confused....

LFS

Nov 21 '05 #22

P: n/a
Dennis,
Your question, as I understand it, is one of the major reasons that Multiple
Inheritance is avoided in some circles.

My understanding that Eiffel.NET (http://www.eiffel.com) requires you to
indicate which method is called, similar to how VB.NET implements
"Implements Interface".

Eiffel.NET supports multiple inheritance on the .NET framework, although the
framework itself does not support multiple inheritance. Which I think is
rather cool! Granted only Eiffel classes can participate in the multiple
inheritance...

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:ED**********************************@microsof t.com...
Your note said that there are "other" .net languages that support multiple
inheiritances. I was asking how a class that inherited from two different
classes would know which property or method of the inheirited classes to
call
if the two different classes happened to have a property or method with
the
same name!

"Larry Serflaten" wrote:

"Dennis" <De****@discussions.microsoft.com> wrote
> Just curious but if you can inheirit two interfaces and both have a
> property
> or method that has the same name, how can you tell which one to use?


How can _who_ tell which one to use? The user or the class developer?

When you implement a member of an interface, the member is marked:

Private Sub SomeMethod() Implements MyInterface.MyMethod

Because both the interface and method are named, the CLR won't get
confused....

LFS

Nov 21 '05 #23

P: n/a
Cor

Thank you for your interesting advise, but how to solve the following
problem.

I'm a car manufacturer and to do that I can use different kind of engines
(let say EngineA, EngineB, etc, each of them having their properties and
methods) but I need also different Shapes (A,B,etc) and Windows 'A,B,C),
etct, etc.

When I assemble a car I need to use the different objects (engines, windows,
shapes,...) and the car itself will have its own properties and methods.

If I understand correctly the concept, I need here to have a multi
inheritance of various objects .

Am I wrong or should I have an other way of thinking ?

Thanks for your help.

--
Bernard Bourée
be*****@bouree.net
"Cor Ligthert" <no************@planet.nl> a écrit dans le message de
news:%2****************@tk2msftngp13.phx.gbl...
Bernard,
Is there a way to overpass the impossibility of VN.NET to accept the multi heritage, that is to allow a class to inherit from TWO mother classes ?
I have always to be very carefully with this kind of texts because there

is some English language in it.

In my opinion is good design build on inheriting. Not on multi heritage.

And inheriting is build on the princible that a class can inherite from its parent class.

And here comes the English language expect, for me can you never inherit
from two mothers. In natural life by instance Mothers can be an inherited
class from Human, where as well can be Fathers. There should never be a need to instance as well from Fathers and Mothers because than you have to use
the class Human.

In my opinion you should avoid doing what you want that in your design, you can make work arounds. However by instance inheriting from cars and from
mamals to create a new class is in my opinon always bad design, what you
should avoid as much as possible.

Just my thought reading this thread

Cor

Nov 21 '05 #24

P: n/a
Cor

Once more thank you so much to try to educate me.
It is more clear for me know.

Regards

--
Bernard Bourée
be*****@bouree.net
"Cor Ligthert" <no************@planet.nl> a écrit dans le message de
news:uC**************@TK2MSFTNGP11.phx.gbl...
Bernard,

You said it yourself,

You make from the class cars a special object of the type car or an
inherrited class by instance trarilers (strange example however it has no
engine) :-)

The car has properties
engines which can be a an object from the class engines (or from an
inherited class from that)
windows which can be a string or an object from the class windows etc.

However the trailer has (when you have not shadowed them) all the properties from the car, which when you have not overriden those are the same as the
Car

I made a simple sample for you from it.
\\\
Imports System.ComponentModel
'This above is only for the <Browsable(false)>
'before somebody say that that is the solution to
'hide a property in the intelisence
Public Module main
Public Sub main()
Dim mycar As New car
Dim mycarengine As New Engine
mycar.Engine = mycarengine
mycar.Engine.CC = 2000
mycarengine.Mark = "Peugeot"
mycar.Window = "Safe glass"
Dim mytrailer As New trailer
mytrailer.Engine = mycarengine
'This does nothing,
'for me is this the same problem as with the
'backgroundproperty of the picturebox
Console.WriteLine("The Car engine brand is a {0} ", _
DirectCast(mycar.Engine, Engine).Mark)
Console.WriteLine("The Car engine cc is {0} ", _
DirectCast(mycar.Engine, Engine).CC.ToString)
Console.WriteLine("The car window is from {0}", mycar.Window)
If mytrailer.Engine Is Nothing Then
Console.WriteLine("The trailer has no engine")
End If
Console.WriteLine("The trailer window is from {0}",
mytrailer.Window)
End Sub
End Module
Public Class car
Private mEngine As Engine
Private mWindow As String
Public Property Engine() As Engine
Get
Return mEngine
End Get
Set(ByVal Value As Engine)
mEngine = Value
End Set
End Property
Public Overridable Property Window() As String
Get
Return mWindow
End Get
Set(ByVal Value As String)
mWindow = Value
End Set
End Property
End Class
Public Class trailer
Inherits car
Sub New()
MyBase.Window = Window
MyBase.Engine = Nothing
End Sub
Public Overrides Property Window() As String
Get
Return "Unsafe glass"
End Get
Set(ByVal Value As String)
MyBase.Window = "Unsafe glass"
End Set
End Property
<Browsable(False)> _
Public Shadows Property Engine() As Engine
'I can not find any solution to hide it from intelisence
'When I make it private it takes direct the base class
Get
End Get
Set(ByVal Value As Engine)
End Set
End Property
End Class
Public Class Engine
Dim mMark As String
Dim mCC As Integer
Public Property Mark() As String
Get
Return mMark
End Get
Set(ByVal Value As String)
mMark = Value
End Set
End Property
Public Property CC() As Integer
Get
Return mCC
End Get
Set(ByVal Value As Integer)
mCC = Value
End Set
End Property
End Class
///

I hope this gives an idea?

Cor
"Bernard Bourée" <be*****@bouree.net>
Cor

Thank you for your interesting advise, but how to solve the following
problem.

I'm a car manufacturer and to do that I can use different kind of engines (let say EngineA, EngineB, etc, each of them having their properties and
methods) but I need also different Shapes (A,B,etc) and Windows 'A,B,C),
etct, etc.

When I assemble a car I need to use the different objects (engines,
windows,
shapes,...) and the car itself will have its own properties and methods.

If I understand correctly the concept, I need here to have a multi
inheritance of various objects .

Am I wrong or should I have an other way of thinking ?

Thanks for your help.

--
Bernard Bourée
be*****@bouree.net
"Cor Ligthert" <no************@planet.nl> a écrit dans le message de
news:%2****************@tk2msftngp13.phx.gbl...
Bernard,

> Is there a way to overpass the impossibility of VN.NET to accept the

multi
> heritage, that is to allow a class to inherit from TWO mother classes ? >
I have always to be very carefully with this kind of texts because there
is
some English language in it.

In my opinion is good design build on inheriting. Not on multi

heritage.
And inheriting is build on the princible that a class can inherite from

its
parent class.

And here comes the English language expect, for me can you never inherit from two mothers. In natural life by instance Mothers can be an
inherited
class from Human, where as well can be Fathers. There should never be a

need
to instance as well from Fathers and Mothers because than you have to use the class Human.

In my opinion you should avoid doing what you want that in your design,

you
can make work arounds. However by instance inheriting from cars and from mamals to create a new class is in my opinon always bad design, what you should avoid as much as possible.

Just my thought reading this thread

Cor



Nov 21 '05 #25

P: n/a
Jay

If I understand correctly your exemple, in order to achieve my multy
inheritance I need to declare as properties in the Class Section, ALL
properties of IFluid and IDRop as well.

This means that If I make a modification in the Fluid Class I need also to
make the same modification the Section Class. Is it correct ?

--
Bernard Bourée
be*****@bouree.net
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> a écrit dans le
message de news:Oh**************@tk2msftngp13.phx.gbl...
Bernard,
In addition to the other comments, you could use one or more Interfaces:

Something like:
Public Interface IFluid
Property Pressure() As Integer
Property Temp() As Integer
Property FlowRate() As Integer
End Interface

Public Class Fluid
Implements IFluid

Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer

Public Property FlowRate() As Integer Implements IFluid.FlowRate
Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property

Public Property Pressure() As Integer Implements IFluid.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IFluid.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

End Class

Public Interface IDrop
Property Diameter() As Integer
Property Temp() As Integer
Property Pressure() As Integer
End Interface

Public Class Drop
Implements IDrop

Private m_diameter As Integer
Private m_pressure As Integer
Private m_temp As Integer

Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property

Public Property Pressure() As Integer Implements IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IDrop.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

End Class

Public Interface ISection
Inherits IFluid
Inherits IDrop
End Interface

Public Class Section
Implements ISection

Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer
Private m_diameter As Integer

Public Property FlowRate() As Integer Implements IFluid.FlowRate
Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property

Public Property Pressure() As Integer Implements IFluid.Pressure,
IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IFluid.Temp, IDrop.Temp Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property

End Class

Then rather then define your parameters as the class, you would define them as the Interface.

For Example:

Public Shared Sub ProcessFluid(ByVal aFluid As IFluid)
Debug.WriteLine(CObj(aFluid).GetType().Name)
Debug.Indent()
Debug.WriteLine(aFluid.Pressure, "Fluid.Pressure")
Debug.WriteLine(aFluid.Temp, "Fluid.Temp")
Debug.WriteLine(aFluid.FlowRate, "Fluid.FlowRate")
Debug.Unindent()
End Sub

Public Shared Sub ProcessDrop(ByVal aDrop As IDrop)
Debug.WriteLine(CObj(aFluid).GetType().Name)
Debug.Indent()
Debug.WriteLine(aDrop.Diameter, "Drop.Diameter")
Debug.WriteLine(aDrop.Temp, "Drop.Diameter")
Debug.WriteLine(aDrop.Pressure, "Drop.Pressure")
Debug.Unindent()
End Sub
Public Shared Sub Main()
Dim aFluid As New Fluid
Dim aDrop As New Drop
Dim aSection As New Section
ProcessFluid(aFluid)
ProcessFluid(aSection)

ProcessDrop(aDrop)
ProcessDrop(aSection)
End Sub

Note you don't need to use three actual interface, you can get by with only defining Fluid or Drop in terms on an interface, then Section could inherit from the other & implement the interface. The key is to use the Interface
instead of the class when you want to accept a Section in addition to the
class... Section could also implement ISection by using delegation to actual Fluid & Drop objects...

Hope this helps
Jay
"Bernard Bourée" <be*****@bouree.net> wrote in message
news:ek**************@TK2MSFTNGP15.phx.gbl...
Well if I try to make it simple

I have one class named FLUID which contains various properties like
Pressure
Temp
FlowRate

An other class named DROP which contains properties like
Diameter
Temp
Pressure

And a last one called SECTION which should contains the properties of
FLUID,
DROP plus some others.
So the solution I have now is to make a copy of the FLUID's properties
inside SECTION

But If I have to change the properties of FLUID I have to remind to do it in
both places.

Thank for your help

--
Bernard Bourée
be*****@bouree.net
"Larry Serflaten" <se*******@usinternet.com> a écrit dans le message de
news:%2****************@tk2msftngp13.phx.gbl...

"Bernard Bourée" <be*****@bouree.net> wrote
> Is there a way to overpass the impossibility of VN.NET to accept the

multi
> heritage, that is to allow a class to inherit from TWO mother classes ?
If there was a often used need for multiple inheritance, then MS would

have
probably found a way to include it. Evidently they decided there wasn't an absolute need that would be common enough for the functionality.

Perhaps if you describe what you want to do, someone can explain how
to do that within the confines of the language you are using....

LFS



Nov 21 '05 #26

P: n/a
Bernard,
Based on Cor's comments.

By "Multiple inheritance" do you mean "IS A" or "HAS A".

For example a Car has a Tire, however a Car is not a Tire.

Is Section is a Fluid? Or does Section have a Fluid?
Is Section is a Drop? Or does Section have a Drop?

In my sample I was showing you have to program Section is a Fluid at the
same time Section is a Drop. Normally you would have Section inherit from
Fluid if Section is a Fluid, when any changes to Fluid would also be
reflected to Section, without any real work on your part per se. However!
you can only inherit from a single base class, hence the Interface &
Implements. When you use a Interface, then any changes to the interface
would need to be reflected in both classes...

For a very good "How To" book on OO in VB.NET check out Robin A.
Reynolds-Haertle's book "OOP with Microsoft Visual Basic .NET and Microsoft
Visual C# .NET - Step by Step" from MS Press.

Hope this helps
Jay


"Bernard Bourée" <be*****@bouree.net> wrote in message
news:eE*************@TK2MSFTNGP10.phx.gbl...
Jay

If I understand correctly your exemple, in order to achieve my multy
inheritance I need to declare as properties in the Class Section, ALL
properties of IFluid and IDRop as well.

This means that If I make a modification in the Fluid Class I need also to
make the same modification the Section Class. Is it correct ?

--
Bernard Bourée
be*****@bouree.net
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> a écrit dans le
message de news:Oh**************@tk2msftngp13.phx.gbl...
Bernard,
In addition to the other comments, you could use one or more Interfaces:

Something like:
Public Interface IFluid
Property Pressure() As Integer
Property Temp() As Integer
Property FlowRate() As Integer
End Interface

Public Class Fluid
Implements IFluid

Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer

Public Property FlowRate() As Integer Implements IFluid.FlowRate
Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property

Public Property Pressure() As Integer Implements IFluid.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IFluid.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

End Class

Public Interface IDrop
Property Diameter() As Integer
Property Temp() As Integer
Property Pressure() As Integer
End Interface

Public Class Drop
Implements IDrop

Private m_diameter As Integer
Private m_pressure As Integer
Private m_temp As Integer

Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property

Public Property Pressure() As Integer Implements IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IDrop.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

End Class

Public Interface ISection
Inherits IFluid
Inherits IDrop
End Interface

Public Class Section
Implements ISection

Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer
Private m_diameter As Integer

Public Property FlowRate() As Integer Implements IFluid.FlowRate
Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property

Public Property Pressure() As Integer Implements IFluid.Pressure,
IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IFluid.Temp,

IDrop.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property

End Class

Then rather then define your parameters as the class, you would define

them
as the Interface.

For Example:

Public Shared Sub ProcessFluid(ByVal aFluid As IFluid)
Debug.WriteLine(CObj(aFluid).GetType().Name)
Debug.Indent()
Debug.WriteLine(aFluid.Pressure, "Fluid.Pressure")
Debug.WriteLine(aFluid.Temp, "Fluid.Temp")
Debug.WriteLine(aFluid.FlowRate, "Fluid.FlowRate")
Debug.Unindent()
End Sub

Public Shared Sub ProcessDrop(ByVal aDrop As IDrop)
Debug.WriteLine(CObj(aFluid).GetType().Name)
Debug.Indent()
Debug.WriteLine(aDrop.Diameter, "Drop.Diameter")
Debug.WriteLine(aDrop.Temp, "Drop.Diameter")
Debug.WriteLine(aDrop.Pressure, "Drop.Pressure")
Debug.Unindent()
End Sub
Public Shared Sub Main()
Dim aFluid As New Fluid
Dim aDrop As New Drop
Dim aSection As New Section
ProcessFluid(aFluid)
ProcessFluid(aSection)

ProcessDrop(aDrop)
ProcessDrop(aSection)
End Sub

Note you don't need to use three actual interface, you can get by with

only
defining Fluid or Drop in terms on an interface, then Section could

inherit
from the other & implement the interface. The key is to use the Interface
instead of the class when you want to accept a Section in addition to the
class... Section could also implement ISection by using delegation to

actual
Fluid & Drop objects...

Hope this helps
Jay
"Bernard Bourée" <be*****@bouree.net> wrote in message
news:ek**************@TK2MSFTNGP15.phx.gbl...
> Well if I try to make it simple
>
> I have one class named FLUID which contains various properties like
> Pressure
> Temp
> FlowRate
>
> An other class named DROP which contains properties like
> Diameter
> Temp
> Pressure
>
> And a last one called SECTION which should contains the properties of
> FLUID,
> DROP plus some others.
> So the solution I have now is to make a copy of the FLUID's properties
> inside SECTION
>
> But If I have to change the properties of FLUID I have to remind to do it > in
> both places.
>
> Thank for your help
>
> --
> Bernard Bourée
> be*****@bouree.net
> "Larry Serflaten" <se*******@usinternet.com> a écrit dans le message de
> news:%2****************@tk2msftngp13.phx.gbl...
>>
>> "Bernard Bourée" <be*****@bouree.net> wrote
>> > Is there a way to overpass the impossibility of VN.NET to accept the
> multi
>> > heritage, that is to allow a class to inherit from TWO mother
>> > classes ? >>
>> If there was a often used need for multiple inheritance, then MS would
> have
>> probably found a way to include it. Evidently they decided there wasn't >> an absolute need that would be common enough for the functionality.
>>
>> Perhaps if you describe what you want to do, someone can explain how
>> to do that within the confines of the language you are using....
>>
>> LFS
>>
>
>



Nov 21 '05 #27

P: n/a
Jay

IS A or HAS A seams to be the main point.

Thanks a lot once more.

I want to take the opportunity to thanks the persons participating in this
news groups for their dedication and willingness to give extense support and
explanation .

--
Bernard Bourée
be*****@bouree.net
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> a écrit dans le
message de news:eA**************@tk2msftngp13.phx.gbl...
Bernard,
Based on Cor's comments.

By "Multiple inheritance" do you mean "IS A" or "HAS A".

For example a Car has a Tire, however a Car is not a Tire.

Is Section is a Fluid? Or does Section have a Fluid?
Is Section is a Drop? Or does Section have a Drop?

In my sample I was showing you have to program Section is a Fluid at the
same time Section is a Drop. Normally you would have Section inherit from
Fluid if Section is a Fluid, when any changes to Fluid would also be
reflected to Section, without any real work on your part per se. However!
you can only inherit from a single base class, hence the Interface &
Implements. When you use a Interface, then any changes to the interface
would need to be reflected in both classes...

For a very good "How To" book on OO in VB.NET check out Robin A.
Reynolds-Haertle's book "OOP with Microsoft Visual Basic .NET and Microsoft Visual C# .NET - Step by Step" from MS Press.

Hope this helps
Jay


"Bernard Bourée" <be*****@bouree.net> wrote in message
news:eE*************@TK2MSFTNGP10.phx.gbl...
Jay

If I understand correctly your exemple, in order to achieve my multy
inheritance I need to declare as properties in the Class Section, ALL
properties of IFluid and IDRop as well.

This means that If I make a modification in the Fluid Class I need also to make the same modification the Section Class. Is it correct ?

--
Bernard Bourée
be*****@bouree.net
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> a écrit dans le
message de news:Oh**************@tk2msftngp13.phx.gbl...
Bernard,
In addition to the other comments, you could use one or more Interfaces:
Something like:
Public Interface IFluid
Property Pressure() As Integer
Property Temp() As Integer
Property FlowRate() As Integer
End Interface

Public Class Fluid
Implements IFluid

Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer

Public Property FlowRate() As Integer Implements IFluid.FlowRate Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property

Public Property Pressure() As Integer Implements IFluid.Pressure Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IFluid.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

End Class

Public Interface IDrop
Property Diameter() As Integer
Property Temp() As Integer
Property Pressure() As Integer
End Interface

Public Class Drop
Implements IDrop

Private m_diameter As Integer
Private m_pressure As Integer
Private m_temp As Integer

Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property

Public Property Pressure() As Integer Implements IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IDrop.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

End Class

Public Interface ISection
Inherits IFluid
Inherits IDrop
End Interface

Public Class Section
Implements ISection

Private m_flowRate As Integer
Private m_pressure As Integer
Private m_temp As Integer
Private m_diameter As Integer

Public Property FlowRate() As Integer Implements IFluid.FlowRate Get
Return m_flowRate
End Get
Set(ByVal value As Integer)
m_flowRate = value
End Set
End Property

Public Property Pressure() As Integer Implements IFluid.Pressure, IDrop.Pressure
Get
Return m_pressure
End Get
Set(ByVal value As Integer)
m_pressure = value
End Set
End Property

Public Property Temp() As Integer Implements IFluid.Temp,

IDrop.Temp
Get
Return m_temp
End Get
Set(ByVal value As Integer)
m_temp = value
End Set
End Property

Public Property Diameter() As Integer Implements IDrop.Diameter
Get
Return m_diameter
End Get
Set(ByVal value As Integer)
m_diameter = value
End Set
End Property

End Class

Then rather then define your parameters as the class, you would define

them
as the Interface.

For Example:

Public Shared Sub ProcessFluid(ByVal aFluid As IFluid)
Debug.WriteLine(CObj(aFluid).GetType().Name)
Debug.Indent()
Debug.WriteLine(aFluid.Pressure, "Fluid.Pressure")
Debug.WriteLine(aFluid.Temp, "Fluid.Temp")
Debug.WriteLine(aFluid.FlowRate, "Fluid.FlowRate")
Debug.Unindent()
End Sub

Public Shared Sub ProcessDrop(ByVal aDrop As IDrop)
Debug.WriteLine(CObj(aFluid).GetType().Name)
Debug.Indent()
Debug.WriteLine(aDrop.Diameter, "Drop.Diameter")
Debug.WriteLine(aDrop.Temp, "Drop.Diameter")
Debug.WriteLine(aDrop.Pressure, "Drop.Pressure")
Debug.Unindent()
End Sub
Public Shared Sub Main()
Dim aFluid As New Fluid
Dim aDrop As New Drop
Dim aSection As New Section
ProcessFluid(aFluid)
ProcessFluid(aSection)

ProcessDrop(aDrop)
ProcessDrop(aSection)
End Sub

Note you don't need to use three actual interface, you can get by with

only
defining Fluid or Drop in terms on an interface, then Section could

inherit
from the other & implement the interface. The key is to use the Interface instead of the class when you want to accept a Section in addition to the class... Section could also implement ISection by using delegation to

actual
Fluid & Drop objects...

Hope this helps
Jay
"Bernard Bourée" <be*****@bouree.net> wrote in message
news:ek**************@TK2MSFTNGP15.phx.gbl...
> Well if I try to make it simple
>
> I have one class named FLUID which contains various properties like
> Pressure
> Temp
> FlowRate
>
> An other class named DROP which contains properties like
> Diameter
> Temp
> Pressure
>
> And a last one called SECTION which should contains the properties of
> FLUID,
> DROP plus some others.
> So the solution I have now is to make a copy of the FLUID's properties > inside SECTION
>
> But If I have to change the properties of FLUID I have to remind to do
it
> in
> both places.
>
> Thank for your help
>
> --
> Bernard Bourée
> be*****@bouree.net
> "Larry Serflaten" <se*******@usinternet.com> a écrit dans le message

de > news:%2****************@tk2msftngp13.phx.gbl...
>>
>> "Bernard Bourée" <be*****@bouree.net> wrote
>> > Is there a way to overpass the impossibility of VN.NET to accept the > multi
>> > heritage, that is to allow a class to inherit from TWO mother
>> > classes

?
>>
>> If there was a often used need for multiple inheritance, then MS would > have
>> probably found a way to include it. Evidently they decided there

wasn't
>> an absolute need that would be common enough for the functionality.
>>
>> Perhaps if you describe what you want to do, someone can explain how
>> to do that within the confines of the language you are using....
>>
>> LFS
>>
>
>



Nov 21 '05 #28

This discussion thread is closed

Replies have been disabled for this discussion.