fb:porticula NoPaste
Syntaxvorschlag Methodenpointer
| Uploader: | MOD |
| Datum/Zeit: | 21.01.2012 22:19:54 |
Function myFunc (x As Integer) As Integer
'...
Return x
End Function
Type myType
dummy As Integer
Declare Static Function myTypeFuncStatic (x As Integer) As Integer
Declare Function myTypeFunc (x As Integer) As Integer
End Type
Function myType.myTypeFuncStatic (x As Integer) As Integer
'...
Return x
End Function
Function myType.myTypeFunc (x As Integer) As Integer
'...
Return x
End Function
'Einfacher Function-Ptr
Dim As Function (x As Integer) As Integer atMyFunc = @myFunc()
Print atMyFunc(0)
'Function-Ptr auf eine statische Methode
Dim As Function (x As Integer) As Integer atMyTypeFuncStatic = @myType.myTypeFuncStatic()
Print atMyTypeFuncStatic(1)
'Function-Ptr auf eine normale Methode
Dim As Function (x As Integer) As Integer atMyTypeFunc = @myType.myTypeFunc()
Dim As myType myTypeVar
Print atMyTypeFunc<myTypeVar>(2)
Sleep



FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!



