How to init a static object ?

TSalm tsalm at free.fr
Sat Mar 15 12:37:49 PDT 2008


Hi all,

I would do something like this below, but DMD return me the error :
  testStaticInit.d(10): Error: non-constant expression new A
on the line "public static A a=new A();"
Is there a simple way to instanciate a static class ?



class A
{
 public this() {}
}

class B
{
 public static A a = new A();

 public this() {}

}

void main()
{
 new B();
}



 Thanks in advance,
 TSalm




More information about the Digitalmars-d-learn mailing list