On Thu, 01 Oct 2009 16:30:43 -0400, Andrei Alexandrescu
<[email protected]> wrote:
Consider:
class A {
abstract void fun() {}
}
The class defines a function that is at the same time abstract (so it
requires overriding in derivees) and has implementation.
Currently the compiler disallows creation of objects of type A, although
technically that is feasible given that A defines the abstract method.
Should A be instantiable? What designs would that help or hinder?
If you want to force a class to be abstract, even though it technically
could be concrete given it has implementations for all functions, you
could allow that by marking the class abstract. i.e.:
abstract class A {
void fun() {}
}
The other side, allowing A to be instantiated, makes no sense whatsoever.
If you (as a class designer) want something to be instantiated, and it has
all methods implemented, why mark it abstract? IMO, it should be a
compiler error to give implementation to an abstract method.
-Steve