forbid field name conflict in class hierarchy

bearophile bearophileHUGS at lycos.com
Sun Nov 14 11:22:56 PST 2010


spir:

> I think the compiler should complain when sub-classes hold fields with the same name as super-classes.

I have a bug report on it:
http://d.puremagic.com/issues/show_bug.cgi?id=5187

C# faces this problem with the "new" keyword that's denotes a field that the programmer wants to hide:

public class Foo {
    public int x = 10;
}
public class Test : Foo {
    new public int x = 20;
    public static void Main() {}
}

Bye,
bearophile


More information about the Digitalmars-d mailing list