Hi guys,

I've the following code:

abstract class a {}
class b : a { this(a* myAttr = null) {} }
class c : a { this(a* myAttr = null) {} }

void main()
{
    auto myb = new b();
    auto myc = new c(&myb);
}

DMD says "Constructor c.this(a* myAttr = null) is not callable using argument types (b*)". I'm confused why it fails because class b and c are both derived from class a and the constructor of class b accepts a pointer of class a.

When I replace "auto myb = new b();" by "a myb = new b();", it works as expected. But then I cannot class-specific functions of class b because I've the instance of the base-class a. So, what's the correct way?

Reply via email to