digitalmars.D.learn - interface assignement implies implicit const cast
- gzp (14/14) Oct 12 2009 Assigning a const instance to an interface implies an implicit cast. Is ...
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
Oct 12 2009








gzp <galap freemail.hu>