Generic Object

BlitzMax Forums/BlitzMax Programming/Generic Object

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hey, I want a generic type in the field i can slap in other type into.

Here's an attempt. I'm sure i'm doing something simple wrong.


Graphics 800,600

Obj:UDO = New UDO




InputType = 1


If 	InputType = 1 Then

	Obj.Anytype = New IntType
	
ElseIf 	InputType = 2 Then
	
	Obj.Anytype = New FloatType
	
EndIf 


Obj.Anytype.Vari = 2

'DrawText String( Obj.Anytype.Vari ),0,0

Flip

WaitKey()



End




Type UDO

	Field Anytype:Object

End Type



Type IntType

	Field Vari

End Type


Type FloatType

	Field Vari#

End Type