non-const function override can cast away const
Steven Schveighoffer
schveiguy at yahoo.com
Mon Nov 5 17:54:59 PST 2007
Don't know if this has already been reported, but it definitely needs
attention.
import std.stdio;
class A
{
int x;
const void f()
{
writefln("A");
}
}
class B : A
{
override void f()
{
x = 2;
writefln("B");
}
}
void main(){
A y = new B;
y.f;
}
[steves at localhost svn]$ dmd testme.d
gcc testme.o -o
testme -m32 -Xlinker -L/home/steves/dmd2/dmd/bin/../lib -lphobos2 -lpthread
-lm
[steves at localhost svn]$ ./testme
B
[steves at localhost svn]$
-Steve
More information about the Digitalmars-d
mailing list