How to override a create function?

BlitzMax Forums/BlitzMax Beginners Area/How to override a create function?

I would check that debug mode is on in BlitzMax IDE.

You can't override functions, when you call
Return testB(Super.Create(newx)

BlitzMax is creating a TestA type then casting to the type TestB which as you can only cast successfully to a base class is returning null.

The following is an example of using Create methods instead of functions which allows you a little more flexibility. The trick is to remember to Return Self from all your Create Methods and use the myblob=new blob.Create() style creation:

Type A
	Method Create:A()
		Return Self
	End Method
End Type

Type B Extends A
	Method Create:B()
		super.Create()
		Return Self
	End Method
End Type

MyB:B=New B.Create()