struct constructors
div0
div0 at users.sourceforge.net
Thu Oct 4 12:00:31 PDT 2007
Steven Schveighoffer wrote:
> OK,
>
> So this code doesn't compile:
>
> struct Y
> {
> int t;
> static Y opCall(int t)
> {
> Y result;
> result.t = t;
> return result;
> }
>
> static Y fromLong(long t)
> {
> return Y(cast(int)t);
> }
> }
>
> Y v1 = Y(5);
> Y v2 = Y.fromLong(5L);
>
>
> and the cryptic error (without a file/line number) is:
> Error: cannot cast int to Y
compiles for me...
Digital Mars D Compiler v1.021
Copyright (c) 1999-2007 by Digital Mars written by Walter Bright
More information about the Digitalmars-d-learn
mailing list