static class

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Feb 17 14:47:12 PST 2013


On Sun, Feb 17, 2013 at 11:46:24PM +0100, Andrej Mitrovic wrote:
> On 2/17/13, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
> > A class that can't be instantiated has a private constructor.
> 
> An alternative to that is:
> 
> final abstract class C
> {
>     static:
> }
> 
> You can't derive from it and you can't instantiate it.

Nice idiom!

This could be D's equivalent to C++ namespaces. ;-)


T

-- 
Obviously, some things aren't very obvious.


More information about the Digitalmars-d-learn mailing list