Is it possible to call the inherited Constructor from a Subclasses Constructor?
This DOES work, but, note I had to create a helper function called constructBase() which seems round about:
public class Base {
public var num : int = 5;
function Base() {}
function Base(num : int) {
this.constructBase(num);
}
function constructBase(num : int) {
this.num = num;
}
}
public class Sub extends Base {
function Sub(num : int) {
super.constructBase(num);
}
function print() {
Debug.Log(this.num);
}
}
This is more along the lines of what I’d expect to be able to do, but this doesn’t work, it will print 5 when creating an instance of the subclass.
public class Base {
public var num : int = 5;
function Base() {}
function Base(num : int) {
this.num = num;
}
function constructBase(num : int) {
this.num = num;
}
}
public class Sub extends Base {
function Sub(num : int) {
Base(num);
}
function print() {
Debug.Log(this.num);
}
}