static class

Michael pr at m1xa.com
Mon Feb 18 13:25:18 PST 2013


Yes, it's comes from C#.

So, there is no static for classes at module level. Good to have 
a msg for it at compile-time.

>import std.stdio;
>
>public final abstract class Test
>{
>    static this() { writeln("in static ctor"); }
>    static :
>        void foo() { writeln("in static method"); }
>}
>
>void main()
>{
>    Test.foo();
>}

public - adds a little bit of verbosity (ref 
http://wiki.dlang.org/Access_specifiers_and_visibility). For now 
is noop.
final - adds a no inheritance.
abstract - disables non-static ctors.

right?


More information about the Digitalmars-d-learn mailing list