private constructors and inheritance

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 29 07:09:25 PDT 2014


On Tuesday, 29 April 2014 at 13:59:30 UTC, John Colvin wrote:
> //blah1.d
>
> class A
> {
>     private this(){}
> }
>
>
> //blah2.d
>
> import blah1;
>
> class B : A {}
>
>
> $ dmd blah1.d blah2.d -lib
> Error: constructor blah1.A.this is not accessible from module 
> blah2
>
> Can someone explain why this can't/doesn't work? Thanks.

Also, I noticed that adding a blank constructor ( this(){} ) to B 
didn't help, but adding a blank template constructor ( this()(){} 
) makes the error go away.


More information about the Digitalmars-d-learn mailing list