private constructors and inheritance

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 29 12:16:58 PDT 2014


On Tuesday, 29 April 2014 at 18:51:15 UTC, ketmar via 
Digitalmars-d-learn wrote:
> On Tue, 29 Apr 2014 13:59:28 +0000
> John Colvin via Digitalmars-d-learn 
> <digitalmars-d-learn at puremagic.com>
> wrote:
>> Can someone explain why this can't/doesn't work? Thanks.
> hm. why it should? there is no 'default' constructors in D, and 
> you
> specifially made explicit one private (i.e. not visible outside 
> the
> module). and adding constructor to B inherits 'private' (not 
> sure if it
> is right though). but templated one generates constructor code 
> 'on
> demand', w/o 'private'.
>
> i think that public constructor in B should work, so this may 
> be bug.
> will wait for somebody more expirienced in language to jump in 
> before
> filling bug report though.

No it shouldn't. Private != protected. If A constructor is 
private, no one outside of same module can access it, not even B 
which is direct descendant.


More information about the Digitalmars-d-learn mailing list