24.3. Self-Referential Classes

Aself-referential class contains a reference member that refers to an object of the same class type. For example, the class declaration in Fig. 24.1 defines the shell of a self-referential class named Node. This type has two Private instance variables—Integer dataValue and Node reference nextNodeReference. Member nextNodeReference references an object of type Node, an object of the same type as the one being declared here—thus the term “self-referential class.” Member nextNodeReference is referred to as a link (i.e., nextNodeReference can be used to “tie” an object of type Node to another object of the same type). Class Node also has two properties—one for instance variable dataValue (named Data) and another for ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.