Base class' constructor is not implicitly inherited for immutable classes. A bug or a feature?

Piotr Mitana via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 19 09:00:56 PDT 2017


Hello, I have this code:

immutable class Base
{
	this() {}
}

immutable class Derived : Base {}

void main()
{
	new immutable Derived();
}

I'd like class Derived to automatically inherit the default 
constructor from Base. However, this is not the case:

main.d(6): Error: class main.Derived cannot implicitly generate a 
default ctor when base class main.Base is missing a default ctor

Is it a bug or it should be like this?


More information about the Digitalmars-d-learn mailing list