Array type conversion
jovo
jovo at at.home
Sun Apr 29 03:59:06 PDT 2007
James Dennett Wrote:
>
> The point is that a reference to a derived reference
> must *not* be converted to a reference to a base
> reference, just as an array of derived references
> must not be converted to an array of base references
> in case any is changed to a reference to an object
> that is not a derived.
>
Interestingly, given:
class B{}
class D: B{}
void f(inout B x){
x = new B();
}
void main(){
D[] a1 = new D[3];
B[] a2 = a1;
f(a1[1]); // Error: cast(B)(a1[1u]) is not an lvalue
f(a2[1]); // naturally works
jovo
More information about the Digitalmars-d
mailing list