How can I limit the number of instances of a class?
<p>As an exercise, I wish to make a class that can't have more than N instances. How can I do that?</p>

<p>Suppose, for example, you want to limit number of connection to database so that no more than N users can connect at the same time. I understand how to make a singleton:</p>

<pre><code>class Singleton {

private:

    Singleton(const Singleton&amp;);

    Singleton();

public :

    static Singleton Instance() {

         static Singleton p;

         if(!p) {

                p = new Singleton;

         }
};
</code></pre>

<p>But if there N > 1 objects, I need help.</p>
