Having a Method operate on many different TYPES.

BlitzMax Forums/BlitzMax Programming/Having a Method operate on many different TYPES.

type extends?

Type Test Extends DebugObject
'	Field Pointer:Int
	
	Method Something(Thing:DebugObject)
		Return Thing.Pointer
	EndMethod
EndType

'----------------
Type A_Object Extends DebugObject
EndType
Type B_Object Extends DebugObject
EndType


	Type DebugObject
		Field Pointer:Int
	EndType
'-----------------

Global OBJ_A:A_Object=New A_Object
OBJ_A.pointer=1024
Global OBJ_B:B_Object=New B_Object
OBJ_B.pointer=512



Global Thistest:test=New test
DebugLog "Test type checking for pointer in OBJ of type A ="+Thistest.Something(OBJ_A)
DebugLog "Test type checking for pointer in OBJ of type B ="+Thistest.Something(OBJ_B)
DebugLog "Test type checking for pointer ="+Thistest.Something(Thistest)