|
![](/i/fill.gif) |
Le 16/05/2013 17:27, Warp nous fit lire :
> scott <sco### [at] scott com> wrote:
>> Is there a C++ equivalent to the C# static class? That would ensure at
>> compile-time that nobody tried to create an(other) instance.
>
You can either have all methods of a class static, or use a singleton
pattern.
> You could use a namespace instead of a class. Private implementation can
> then all go to the source file, away from the header file.
>
> On the other hand, this limits where you can use this "pseudoclass" and
> it could be difficult to maintain backwards compatibility if you ever
> wanted to change it so that more than one instance could be created.
>
> Of course you could have a class that only has static member functions...
>
Post a reply to this message
|
![](/i/fill.gif) |