hiding a class property behind a method
luka8088
luka8088 at owave.net
Sat Feb 22 09:21:49 PST 2014
It seems to me that the following code should be illegal, but I am
uncertain of it so I am posting here for a confirmation before I post it
on bug tracker:
http://dpaste.dzfl.pl/dae728734cc6
import std.stdio;
class A {
string x () { return "A"; };
}
class B : A {
override string x () { return "B"; };
}
class C : A {
string x = "C"; // should this be illegal?
}
void main () {
A o1 = new B();
writeln(o1.x); // B
A o2 = new C();
writeln(o2.x); // A
}
More information about the Digitalmars-d-learn
mailing list