class creation in module scope?

Hendrik Renken funsheep at gmx.net
Wed Mar 21 14:12:41 PDT 2007


Hi,
i am having some trouble figuring out, why i cant instantiate my class 
within module-scope.

Problem:

### A.d File ###
module foo.A;

import foo.B;


public MyClass my = new MyClass();

/... some functions .../



### B.d File ###
module foo.B;


class MyClass
{
     /... some functions .../
}


bud (using gdc) complains:
foo/A.d:6: Error: non-constant expression new MyClass


what am i doing wrong. thought this little example would be the same as 
on the Reference-Page on digitalmars.com

thanks for you help,
hendrik


More information about the Digitalmars-d-learn mailing list