Inheritance of purity

Jonathan M Davis jmdavisProg at gmx.com
Sat Feb 25 16:19:18 PST 2012


On Saturday, February 25, 2012 18:11:27 Andrei Alexandrescu wrote:
> On 2/25/12 2:44 PM, Walter Bright wrote:
> > On 2/25/2012 9:53 AM, deadalnix wrote:
> >> And suddenly, the override doesn't override the same thing anymore.
> >> Which is
> >> unnacceptable.
> > 
> > class A {
> > void fun() const { }
> > void fun() { }
> > }
> > 
> > class B : A {
> > override void fun() { }
> > }
> > 
> > ----
> > 
> > dmd -c foo
> > foo.d(6): Error: class foo.B use of foo.A.fun() hidden by B is deprecated
> 
> Hm, the issue there is that now both overloads of fun must be overridden.

Except that that's already normally the case. If you had

class A
{
    void func(int i) {}
    void func(float i) {}
}

class B
{
    override void func(int i) {}
}

then the float version is not in B's overload set, and you have to add an 
alias.

class b
{
    alias A.func func;
    override void func(int i) {}
}

Though I suppose that the difference is that with const, it's giving you an 
error, and with this, it isn't. Perhaps that's what your concern is.

- Jonathan M Davis


More information about the Digitalmars-d mailing list