Anonymous nested class of problems

Tomek Sowiński just at ask.me
Sat Dec 12 10:23:51 PST 2009


Dnia 12-12-2009 o 15:00:56 div0 <div0 at users.sourceforge.net> napisał(a):

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Tomek Sowiñski wrote:
>> Dnia 12-12-2009 o 13:09:49 Tomek Sowiñski <just at ask.me> napisa³(a):
>>
>>> Error: no constructor for __anonclass10
>>
>> This one seems to be unrelated to anonymous stuff.
>>
>> class M {
>>     this(byte a) { _a = a; }
>>     byte _a;
>>     byte a() { return _a; };
>>
>>     static m = new M(3);
>> }
>>
>> I get: Error: no constructor for M.
>>
>>
>> Tomek
>
> Well for this one, you're doing it wrong. You want:
>
> class M {
>     this(byte a) { _a = a; }
>     byte _a;
>     byte a() { return _a; };
>
>     static M m;
>
>     static this() {
>         m = new M(3);
>     }
> }

So it's the same when I get the "non-constant expression..." error and  
have to put in static ctors? Then what's with the "no constructor for M"?


Tomek


More information about the Digitalmars-d-learn mailing list