The Status of Const
Tomek Sowiński
just at ask.me
Fri Aug 13 17:52:47 PDT 2010
Walter Bright napisał:
> But there is a solution:
>
> const(Object)* o;
Interesting. How do you cook that with polymorphism? This doesn't work:
interface I { }
class A : I {}
void main() {
immutable A a = new immutable(A);
immutable(A)* ap = &a;
// Error: cannot implicitly convert expression (ap) of type immutable(A)* to immutable(I)*
immutable(I)* ip = ap;
}
BTW, should this work?:
immutable(A)* ap = &new immutable(A);
Now it fails with "new immutable(A) is not an lvalue".
Tomek
More information about the Digitalmars-d
mailing list