Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / November 2004



Tip: Looking for answers? Try searching our database.

inclusion

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
benouz - 30 Nov 2004 08:20 GMT
can anyone help me abou tinclusion in VB6
i've read it's a kind of class heritage
but i don't understand what i can do with , and how
thanks
Dag Sunde - 30 Nov 2004 10:59 GMT
> can anyone help me abou tinclusion in VB6
> i've read it's a kind of class heritage
> but i don't understand what i can do with , and how
> thanks

Never heard about it...

Can it be that you mean "Inheritance by Containment"?

Meaning that you include an instance og an existing class
in your new one, thereby getting access to (inheriting) all
its methods & attributes?

something like this:

' --- Parent (Contained) class -------------------------
private m_sName As String

Public Property let Name(byval s As String)
   m_sName = s
End property

Public Property Get Name() As String
   Name = m_sName
End property

Public Sub Print()
   Debug.Print Me.Name
End Sub

' --- Child (containing) class -------------------------
private m_sPhone As String
private m_oParent as CParent

Public Property let Phone(byval s As String)
   m_sPhone = s
End property

Public Property Get Phone() As String
   Phone = m_sPhone
End property

' Here I make wrapper methods for Parent, to
' Completely hide the containment.
Public Property let Name(byval s As String)
   m_oParent.Name = s
End property

Public Property Get Name() As String
   Name = m_oParent.Name
End property

Public Sub Print()
   Debug.Print m_oParent.Name
   Debug.print Me.Phone
End Sub

' Another alternative, is to expose the contained class like this:
Public Property Get Parent() as CParent
   Set Parent = m_oParent
End Property

Private Sub Class_Initialize()
   Set m_oParent = New CParent
End Sub

Private Sub Class_Terminate()
   Set m_oParent = Nothing
End Sub

' ----------Use ------------
...
Dim m_oChild as CChild
Set m_oChild = New CChild

m_oChild.Name = "Dag"
m_oChild.Phone = "370 12 666"
m_oChild.Print

' Or with an exposed parent:
m_oChild.Parent.Name = "Dag"
m_oChild.Phone = "370 12 666"
m_oChild.Print
...

Signature

Dag.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.