October 12, 2009 interface assignement implies implicit const cast | ||||
---|---|---|---|---|
| ||||
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 |
Copyright © 1999-2021 by the D Language Foundation