Consider the following:
abstract class Singleton : Object {
private static Singleton _instance = null;
public static Singleton instance() {
if (instance == null) {
instance = // constructor call goes here
}
return instance;
}
}
class Foo : Singleton {
Foo() {}
}
var test = Foo.instance();
I would like to implement a singleton in an abstract class. My question is: How can I refer to the subclass constructor from Singleton.instance()
?