Opt-out polymorphism?

Sean Eskapp eatingstaples at gmail.com
Sun Feb 13 13:34:04 PST 2011


Is there a way to specify that a function is nonvirtual, but can still be
"overriden" in base classes? e.g.

class A
{
    void foo()
    {
        writeln("A");
    }
}

class B : A
{
    void foo()
    {
        writeln("B");
    }
}

void main()
{
    (new A).foo();
    (new B).foo();
}

Should output:
A
B

Is there a way to do this?


More information about the Digitalmars-d-learn mailing list