interface assignement implies implicit const cast
gzp
galap at freemail.hu
Mon Oct 12 00:24:52 PDT 2009
Assigning a const instance to an interface implies an implicit cast. Is it acceptable for the const-correctness ??
interface I { void foo(); }
class C : I { void foo() { writeln("a"); } }
...
C c = new C;
I i = c; // ok
c.foo(); // ok
i.foo(); // ok
const C cc = c;
I ci = cc; // no error , why ???
// cc.foo(); // compile time error - ok
ci.foo(); // const correctness overridden ???
Thanks
More information about the Digitalmars-d-learn
mailing list