RosettaCodeData/Task/Polymorphic-copy/FreeBASIC/polymorphic-copy.basic

29 lines
389 B
Plaintext

Type T
method As Sub(pthis As T Ptr)
End Type
Type S Extends T
dato As Integer
End Type
Sub TMethod(pthis As T Ptr)
Print "T method"
End Sub
Sub SMethod(pthis As S Ptr)
Print "S method, dato = "; pthis->dato
End Sub
Sub CallMethod(pthis As T Ptr)
pthis->method(pthis)
End Sub
Dim As T tt
tt.method = @TMethod
Dim As S ss
ss.method = @SMethod
ss.dato = 123
Sleep