amitpethkar wrote:
> Hi All,
>
> I want to know is it possible to limit the instances of C++ class.
Yes, it is.
> for example
> Suppose there is 1 instance created of a class and if you create
> other instances they will refer to 1st instance itself instead of
> constructing more objects
This special (and most useful) case is called "Singleton Design Pattern".
For single-threaded applications the implementation is reasonably
straightforward. Google for it, or better, check out Design Patterns by
Gamma et al. (ISBN 0201633612) to learn more about this and other design
patterns.
|