digitalmars.D - non-const function override can cast away const
- Steven Schveighoffer (31/31) Nov 05 2007 Don't know if this has already been reported, but it definitely needs
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 localhost svn]$ dmd testme.d
gcc testme.o -o
testme -m32 -Xlinker -L/home/steves/dmd2/dmd/bin/../lib -lphobos2 -lpthread
-lm
[steves localhost svn]$ ./testme
B
[steves localhost svn]$
-Steve
Nov 05 2007








"Steven Schveighoffer" <schveiguy yahoo.com>