function defaults must be constant

BlitzMax Forums/BlitzMax Programming/function defaults must be constant

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.

You could do this:

Framework BRL.Blitz
Import BRL.StandardIO

Type t1
	Field val1:Int
	Field val2:Int
	Field val3:Int

	Function create:t1()
		Local retval:t1=New t1
		retval.val1=5
		retval.val2=10
		retval.val3=15
		Return retval
	EndFunction
EndType

Type t2
	Method foo(v:t1=Null)
		If (v=Null)
			v=t1.Create()
		Endif
		
		bar(v)
	End Method 
	
	Method bar(v:t1)
		DebugLog(v.val1)
		DebugLog(v.val2)
		DebugLog(v.val3)
	EndMethod
EndType

Type t2ext Extends t2
	Method bar(v:t1)
		Print "Overridden method! - " + v.val1 + " - " + v.val2 + " - " + v.val3
	End Method
End Type

Local meep:t2=New t2
Local baz:t2=New t2ext

meep.foo()
baz.foo()