How do you pass parameters to the constructor when creating an anonymous class in D -
i how create anonymous class
class {} class b { anonymous = new class { ... }; }
but if has constructor, , no default constructor.
class { init(string somearg) { } } class b { anonymous = new class { ... };??? }
how pass parameter constructor?
just implement default constructor calls parent constructor super
:
class { this(string somearg) {} } void main() { anonyomus = new class { this() { super("hello"); } }; }
Comments
Post a Comment