Abstract functions in child classes
Steven Schveighoffer
schveiguy at yahoo.com
Fri Dec 2 04:08:15 PST 2011
On Fri, 02 Dec 2011 03:06:37 -0500, mta`chrono
<chrono at mta-international.net> wrote:
> Even if the current behavior (what Adam mentioned) is not a bug, I think
> it seems to be a pitfall for std::programmer. The language/compiler
> should be more restrictive in this case.
No, this is not a matter of allowing an invalid situation, the OP's code
is perfectly viable and legal. Here is a simpler example:
abstract class Parent
{
abstract void foo();
}
class Child : Parent
{
override void foo() {}
}
void main()
{
Parent parent;
parent = new Child();
}
why should it be disallowed to declare a variable of abstract type? You
aren't instantiating it. It's the act of instantiation which is not and
should not be allowed.
-Steve
More information about the Digitalmars-d-learn
mailing list