inheritance from abstract broken?

Jacob Carlborg doob at me.com
Wed Jan 8 05:48:44 PST 2014


On 2014-01-08 13:22, evilrat wrote:
> Greetings everyone,
>
> i have the code where i have to keep pointers to so storage(context
> dependent stuff), so i tried declare abstract class with ctors and it
> didn't worked.
>
> ------- [code]
>
> class MyContext;
>
> abstract class MyObject
> {
>     // yet another bug? all descendants errors no default ctor...
>     this() {}
>
>     this(MyContext mc)
>     {
>     }
>
>     MyContext _owner;
> }
>
> class MyObjectA : MyObject
> { ... }
>
> //inside MyContext.CreateObj
> MyObject CreateMyObj()
> {
> auto obj = new MyObjectA(this) // two errors produced
>
> ... do something with obj before returning it ...
> return obj;
> }
>
> errors:
> -----------
> Error: no constructor for MyObjectA
> Error: constructor MyObjectA.this () is not callable using argument
> types (MyContext)
> --------
>
> am i wrong about abstract classes usage in D or this is a bug?

Unfortunately constructors are not inherited.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list