Re: Limit Object Instances

Discussion in 'C++' started by Dimitris Kamenopoulos, Jun 26, 2003.

  1. 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.
    Dimitris Kamenopoulos, Jun 26, 2003
    #1
    1. Advertising

  2. Dimitris Kamenopoulos

    amitpethkar Guest

    Dimitris Kamenopoulos <> wrote in message news:<bdeshs$2jmi$>...
    > 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.


    Thank you very much. I learnt concept called Singleton design pattern .
    amitpethkar, Jun 27, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dhruv
    Replies:
    6
    Views:
    722
    Dhruv
    Jul 2, 2003
  2. John Wohlbier
    Replies:
    2
    Views:
    357
    Josiah Carlson
    Feb 22, 2004
  3. Replies:
    1
    Views:
    1,065
    Victor Bazarov
    Jun 28, 2005
  4. Replies:
    8
    Views:
    445
    James Stroud
    Jan 29, 2009
  5. Jonathan Wood
    Replies:
    6
    Views:
    458
    Jonathan Wood
    May 5, 2009
Loading...

Share This Page