Interface/abstract constructors
Jonathan M Davis
jmdavisProg at gmx.com
Mon May 16 12:40:11 PDT 2011
On 2011-05-16 12:32, useo wrote:
> Hey guys,
>
> is there any chance to create an abstract constructor like:
>
> abstract class ABC {
>
> abstract this();
>
> }
>
> DMD always says "...this non-virtual functions cannot be abstract" -
> when I use an interface like:
>
> interface ABC {
>
> this();
>
> }
>
> I get a similar error: "...constructors, destructors, postblits,
> invariants, unittests, new and delete functions are not allowed in
> interface ABC"
>
> Is there any solution or is it possible to create such inheritances
> in DMD?
An abstract constructor makes no sense. It also makes no sense for an
interface to have a constructor. A constructor is specific to the class that
it's on. It is not virtual at all and has nothing to do with the inheritance
hierarchy beyond the fact that subclasses can and will call the constructors
of base classes in their own constructors.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list