Constructor and Destructor for Types

BlitzMax Forums/BlitzMax Programming/Constructor and Destructor for Types

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.

Those do exist, but you have to declare them and you'll have to specify what they should do when they are created/destroyed:
Type test
	Method New() ' Constructor method
		Print "Hey, you've just created a new test-instance"
	End Method

	Method Delete() ' Destructor method
		Print "You've just destroyed a test-instance"
	End Method
End Type

a:test = New test ' Create a new instance of "test"

a = Null ' Set "a" to point to nothing (so it can be destroyed at the next FlushMem)
FlushMem ' Destroy all unreferenced objects