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
27 2212
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
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****@discuss ions.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.MyM ethod
Because both the interface and method are named, the CLR won't get confused....
LFS
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****@discuss ions.microsoft. com> wrote in message
news:ED******** *************** ***********@mic rosoft.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****@discuss ions.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.MyM ethod
Because both the interface and method are named, the CLR won't get confused....
LFS
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******** ********@tk2msf tngp13.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
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******** ******@TK2MSFTN GP11.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.Componen tModel 'This above is only for the <Browsable(fals e)> '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.Mar k = "Peugeot" mycar.Window = "Safe glass" Dim mytrailer As New trailer mytrailer.Engin e = mycarengine 'This does nothing, 'for me is this the same problem as with the 'backgroundprop erty of the picturebox Console.WriteLi ne("The Car engine brand is a {0} ", _ DirectCast(myca r.Engine, Engine).Mark) Console.WriteLi ne("The Car engine cc is {0} ", _ DirectCast(myca r.Engine, Engine).CC.ToSt ring) Console.WriteLi ne("The car window is from {0}", mycar.Window) If mytrailer.Engin e Is Nothing Then Console.WriteLi ne("The trailer has no engine") End If Console.WriteLi ne("The trailer window is from {0}", mytrailer.Windo w) 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(Fals e)> _ 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******** ********@tk2msf tngp13.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
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******** ******@tk2msftn gp13.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(By Val aFluid As IFluid) Debug.WriteLine (CObj(aFluid).G etType().Name) Debug.Indent() Debug.WriteLine (aFluid.Pressur e, "Fluid.Pressure ") Debug.WriteLine (aFluid.Temp, "Fluid.Temp ") Debug.WriteLine (aFluid.FlowRat e, "Fluid.FlowRate ") Debug.Unindent( ) End Sub
Public Shared Sub ProcessDrop(ByV al aDrop As IDrop) Debug.WriteLine (CObj(aFluid).G etType().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(aF luid) ProcessFluid(aS ection)
ProcessDrop(aDr op) ProcessDrop(aSe ction) 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******** ******@TK2MSFTN GP15.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*******@usin ternet.com> a écrit dans le message de news:%2******** ********@tk2msf tngp13.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
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******** *****@TK2MSFTNG P10.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******** ******@tk2msftn gp13.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(By Val aFluid As IFluid) Debug.WriteLine (CObj(aFluid).G etType().Name) Debug.Indent() Debug.WriteLine (aFluid.Pressur e, "Fluid.Pressure ") Debug.WriteLine (aFluid.Temp, "Fluid.Temp ") Debug.WriteLine (aFluid.FlowRat e, "Fluid.FlowRate ") Debug.Unindent( ) End Sub
Public Shared Sub ProcessDrop(ByV al aDrop As IDrop) Debug.WriteLine (CObj(aFluid).G etType().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(aF luid) ProcessFluid(aS ection)
ProcessDrop(aDr op) ProcessDrop(aSe ction) 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******** ******@TK2MSFTN GP15.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*******@usin ternet.com> a écrit dans le message de > news:%2******** ********@tk2msf tngp13.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 >> > >
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******** ******@tk2msftn gp13.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******** *****@TK2MSFTNG P10.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******** ******@tk2msftn gp13.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(By Val aFluid As IFluid) Debug.WriteLine (CObj(aFluid).G etType().Name) Debug.Indent() Debug.WriteLine (aFluid.Pressur e, "Fluid.Pressure ") Debug.WriteLine (aFluid.Temp, "Fluid.Temp ") Debug.WriteLine (aFluid.FlowRat e, "Fluid.FlowRate ") Debug.Unindent( ) End Sub
Public Shared Sub ProcessDrop(ByV al aDrop As IDrop) Debug.WriteLine (CObj(aFluid).G etType().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(aF luid) ProcessFluid(aS ection)
ProcessDrop(aDr op) ProcessDrop(aSe ction) 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******** ******@TK2MSFTN GP15.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*******@usin ternet.com> a écrit dans le message
de > news:%2******** ********@tk2msf tngp13.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 >> > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ajikoe |
last post by:
Hello,
Is anyone has experiance in running python code to run multi thread
parallel in multi processor. Is it possible ?
Can python manage which cpu shoud do every thread?
Sincerely Yours,
Pujo
|
by: * ProteanThread * |
last post by:
but depends upon the clique:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=954drf%24oca%241%40agate.berkeley.edu&rnum=2&prev=/groups%3Fq%3D%2522cross%2Bposting%2Bversus%2Bmulti%2Bposting%2522%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den
...
|
by: frankenberry |
last post by:
I have multi-page tiff files. I need to extract individual frames from the
multi-page tiffs and save them as single-page tiffs. 95% of the time I
receive multi-page tiffs containing 1 or more black and white CCITT4
compressed files (frames) inside the tiff. Every now and then I receive a
mixture of black and white CCITT4 and JPEG compressed files, and sometimes
just multi-page tiffs with JPEG only. The code runs great when dealing with
the...
|
by: cody |
last post by:
What are multi file assemblies good for?
What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a
single multi file assembly (A.DLL+A.NETMODULE)?
|
by: mimmo |
last post by:
Hi! I should convert the accented letters of a string in the correspondent
letters not accented. But when I compile with -Wall it give me:
warning: multi-character character constant
Do the problem is the charset? How I can avoid this warning? But the worst
thing isn't the warning, but that the program doesn't work! The program
execute all other operations well, but it don't print the converted
letters: for example, in the string...
| |
by: Shane Story |
last post by:
I can seem to get the dimensions of a frame in a multiframe tiff.
After selecting activeframe, the Width/Height is still really much larger
than the page's actual dimensions.
When I split a TIFF to several PNG files this causes a problem, becuase the
resulting image is (the page to the far left and a lot of black space
surrounding it and a filesize that is larger than needed.
Any ideas?
|
by: bobwansink |
last post by:
Hi, I'm relatively new to programming and I would like to create a C++
multi user program. It's for a project for school. This means I will
have to write a paper about the theory too. Does anyone know a good
place to start looking for some theory on the subject of multi user
applications?
I know only bits and pieces, like about transactions, but a compendium
of possible approches to multi user programming would be very
appreciated!
|
by: Sabri.Pllana |
last post by:
We apologize if you receive multiple copies of this call for papers.
***********************************************************************
2008 International Workshop on Multi-Core Computing Systems
(MuCoCoS'08)
Barcelona, Spain, March 4 - 7, 2008; in conjunction with CISIS'08.
<http://www.par.univie.ac.at/~pllana/mucocos08>
***********************************************************************
Context
|
by: mknoll217 |
last post by:
I am recieving this error from my code:
The multi-part identifier "PAR.UniqueID" could not be bound.
The multi-part identifier "Salary.UniqueID" could not be bound.
The multi-part identifier "PAR.UniqueID" could not be bound.
The multi-part identifier "PAR.PAR_Status" could not be bound.
The multi-part identifier "Salary.New_Salary" could not be bound.
The multi-part identifier "Salary.UniqueID" could not be bound.
The multi-part...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |