Unannotated abstract classes
Mariusz Gliwiński
alienballance at gmail.com
Wed Aug 17 23:39:04 PDT 2011
<code>
abstract class Parent {
abstract void method();
}
class Child : Parent {}
void main(string[] args) {
new Child;
}
</code>
<output>
src/test.d(10): Error: cannot create instance of abstract class Child
src/test.d(10): Error: function method is abstract
</output>
Is this really what should happen? AFAIK error should be recognized when not
overwriting abstract method in non-abstract class.
It reminds me C++, but i don't really see a point in doing like that. Don't
you think it's a flaw?
By saying "Classes become abstract if they are defined within an abstract
attribute, *or if any of the virtual member functions within it are declared
as abstract*." you let confusing situations happen. If i wouldn't instantiate
my Child class, i could easily think, that my Child class is not-abstract,
ship library, and have a problem.
Well, I'm almost sure there *is* a reason why both languages are designed like
that, but it would be great to know it.
Sincerely,
Mariusz Gliwiński
More information about the Digitalmars-d
mailing list