自己指向自己的类

定义一个Node.cls类文件

Public Data As String

Public NextNode As Node

应用示例

Private Sub Command1_Click()

Dim a As Node, b As Node, c As Node

Set a = New Node

Set b = New Node

Set c = New Node

a.Data = “123”

b.Data = “456”

c.Data = “789”

Set a.NextNode = b

Set b.NextNode = c

Set c.NextNode = Nothing

Dim d As Node

Set d = a

MsgBox d.Data

Set d = a.NextNode

MsgBox d.Data

Set d = a.NextNode.NextNode

MsgBox d.Data

End Sub

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注