POV-Ray : Newsgroups : povray.off-topic : Adventures with C++ : Re: An actual C++ question Server Time
29 Jul 2024 00:24:27 EDT (-0400)
  Re: An actual C++ question  
From: Le Forgeron
Date: 16 May 2013 13:19:26
Message: <5195151e$1@news.povray.org>
Le 16/05/2013 17:27, Warp nous fit lire :
> scott <sco### [at] scottcom> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.