static initialization question
    Weed 
    resume755 at mail.ru
       
    Wed Dec 10 14:25:25 PST 2008
    
    
  
moved from digitalmars.D
> Re: static initialization question 	Digital Mars
> Benjamin Shropshire (ao at pathlink.com) 	2008/12/10 16:46
> 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.
But my class does not contain data that need initialization and can be created
in compile time
    
    
More information about the Digitalmars-d-learn
mailing list