Anonymous nested class of problems
div0
div0 at users.sourceforge.net
Sat Dec 12 14:57:59 PST 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Tomek Sowiński wrote:
> 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?
Yes I think.
> Then what's with the "no constructor for M"?
Don't know.
It's best not to read too much into DMDs error messages, they leave a
lot to be desired.
- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFLJB/3T9LetA9XoXwRAtSOAJ9tOP6uJiL6bvxtKZmiW8EMTDmOcQCfbOxs
6f+K154WRQu9NkYKdcDJ2fU=
=ueMn
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-learn
mailing list