It's a very broad question but possible reasons include:
A property of a class being another class
Using inherits to extend behaviour - eg create a base class 'Individual'
that handles Name and Addess functionality
This can then be inherited to a customer class, a contact, a patient etc
Have alook at the topic Visual Basic Language Concepts - Inheritance in
MSDN for more
JoseM,
As the others suggest, can you be a little more specific in what you are
asking?
Do you mean a nested class?
Public Class Class1
Private Class Class2
End Class
End Class
Having Class2 nested inside of Class1 is a form of Encapsulation, I would
use this when Class2 is an implementation detail of Class1 and Class2 is not
needed anyplace else, such as the Node class of a LinkedList class, where
the Node represents the "links" in the LinkedList.
Something like (greatly simplified):
Public Class LinkedList
Private Class Node
Public Data As Object
Public Next As Node
Public Previous As Node
End Class
Private m_head As Node
Private m_tail As Node
Public Sub Add(data As Object)
Dim node As New Node
node.Data = data
node.Next = m_head
node.Previous = Nothing
m_head = node
End Sub
End Class
The Node class is nested inside of LinkedList as it is not useful outside of
the context of a LinkedList. Having Node private to LinkedList ensures that
only LinkedList is able to use the Node class.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.