December 10, 2008 static initialization question | ||||
---|---|---|---|---|
| ||||
why I can not initialize static variable this way: static MyClass c = new MyClass; Error: non-constant expression new MyClass (dmd 2.014) |
December 10, 2008 Re: static initialization question | ||||
---|---|---|---|---|
| ||||
Posted in reply to Weed | Reply to Weed,
> why I can not initialize static variable this way:
>
> static MyClass c = new MyClass;
>
> Error: non-constant expression new MyClass
>
> (dmd 2.014)
>
this NG is more or less dead. The digitalmars.d.learn NGs would be a better choice.
Only compile time constant values are legal for static initializers because they are initialized at compile time as part of the static data segments.
|
Copyright © 1999-2021 by the D Language Foundation