The Status of Const
Leandro Lucarella
luca at llucax.com.ar
Fri Aug 13 18:24:24 PDT 2010
Tomek Sowiński, el 14 de agosto a las 02:52 me escribiste:
> 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".
I don't think so, you're taking the address of a temporary.
--
Leandro Lucarella (AKA luca) http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Did you see the frightened ones?
Did you hear the falling bombs?
Did you ever wonder why we had to run for shelter when the promise of a
brave new world unfurled beneath a clear blue sky?
More information about the Digitalmars-d
mailing list