www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - abstract / private

This may not be a bug in the language, but if not then it's one in the compiler:


public abstract class Base
{
public:
    void method()
    {
        impl();
    }

private:
    abstract void impl();
}

public class Sub1
    : public Base
{
private:
    override void impl()
    {
        printf("Sub1\n");
    }
}
public class Sub2
    : public Base
{
private:
    override void impl()
    {
        printf("Sub2\n");
    }
}

int main()
{
    Base base = new Sub1();

    base.method();

    return 1;
}

This yields

    abs.obj(abs)
     Error 42: Symbol Undefined _D3abs4Base4implFZv

If we provide an impl for Base::impl(), then it calls that. ;(

If the language prohibits the declaration of overridable/overriden methods as
private, then the compiler should let us know that that's the case.
Jun 02 2004