fb:porticula NoPaste
mdList mit Base Ptr und Child Objects
Uploader: | MOD |
Datum/Zeit: | 13.10.2014 20:01:17 |
Type Tier Extends Object
Declare Constructor ()
As Integer beine
End Type
Constructor Tier()
End Constructor
Type Hund Extends Tier
Declare Constructor (anzahlBeine As Integer)
End Type
Constructor Hund(anzahlBeine As Integer)
This.beine = anzahlBeine
End Constructor
Type Affe Extends Tier
Declare Constructor (anzahlBeine As Integer)
End Type
Constructor Affe(anzahlBeine As Integer)
This.beine = anzahlBeine
End Constructor
#Include Once "md/util/mdList.bi"
mdListDeclare(Tier, Ptr)
Dim As mdList(Tier, Ptr) tiere
tiere.add(New Hund(4))
tiere.add(New Affe(2))
Dim As Tier Ptr currentTier
ForEach(Tier, currentTier In tiere, Ptr)
If *currentTier Is Hund Then
Print "Der Hund hat " & currentTier->beine & " Beine."
ElseIf *currentTier Is Affe Then
Print "Der Affe hat " & currentTier->beine & " Beine."
Else
Print "Das Tier ist nicht bekannt."
EndIf
NextEach
Sleep