Anonymous nested class of problems

div0 div0 at users.sourceforge.net
Sat Dec 12 06:00:56 PST 2009


-----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);
    }
}

- --
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/

iD8DBQFLI6IYT9LetA9XoXwRAmmrAKCQYcX8qyXXxYMau4gVyAbEM3PWpACfS0uU
1wc11d9lU608J+ZSiEH77AE=
=svdA
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-learn mailing list