Mixin a constructor ?

BCS none at anon.com
Sat Sep 19 12:19:57 PDT 2009


Hello Jacob,

> Is it supposed to possible to mixin a constructor? The code below
> doesn't compile. The error: is "main.d(23): Error: constructor
> main.A.this() does not match parameter types (int)
> main.d(23): Error: expected 0 arguments, not 1"

IIRC mixins can't overload with other mixins or non mixins so if you were 
to drop the this() that should work. OTOH I'd be surprised if you can do 
that without breaking something else in the general case.

> template C ()
> {
> this (int i)
> {
> }
> }
> class A
> {
> mixin C;
> this ()
> {
> }
> }
> void main ()
> {
> auto a = new A(3);
> }





More information about the Digitalmars-d mailing list