Constructor limitations?

BlitzMax Forums/BlitzMax Programming/Constructor limitations?

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.

verfum, you can't have constructors with arguments, so although you can call the base class's constructor, it wouldn't do any good(and would probably result in a compiler error, since I don't know that you can directly call either the constructor or destructor).

Your best bet is to write a function to create a new object, then call a method that will initialize the object with the arguments passed to the function. Something like this:
Type Foo Extends Bar
    Method _initfoo( i:Int )
        _initbar( something else )
        do some more stuff here, look important
    End Method
End Type

Function CreateFoo:Foo( i:Int )
    Local this:Foo = New Foo
    this._initfoo( i )
    Return this
End Function
I wouldn't recommend placing a Create function in the type, as it might prove troublesome if it turns out you need to have the same arguments as a base class's Create function. Can't remember if that is the case, so you'd have to test it to find out.

Ked: It's a semi-colon, not a comma.