CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Thread: singleton class

  1. #1
    Join Date
    Nov 2004
    Posts
    32

    singleton class

    what is singleton class?what are its advantages?elaborate..

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: singleton class

    There can be only a single instance of a singleton. The advantage is that all users communicate with the same object without having to explicitly pass a reference to the object through out the code or using a global variable
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Nov 2004
    Posts
    32

    Re: singleton class

    How can I implement singleton class?Explain with sample program.

  4. #4
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: singleton class

    There are hundreds of existing samples...Do a search, if you have questions regarding a specific sample, I will try to help....

    gurus help those who help themselves...ps:we dont do homework...
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  5. #5
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

  6. #6
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: singleton class


  7. #7
    Join Date
    Apr 1999
    Location
    Altrincham, England
    Posts
    4,470

    Re: singleton class

    Did no-one else think that they sounded like homework questions?

    A "please" would have been nice...
    Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
    --
    Sutter and Alexandrescu, C++ Coding Standards

    Programs must be written for people to read, and only incidentally for machines to execute.

    --
    Harold Abelson and Gerald Jay Sussman

    The cheapest, fastest and most reliable components of a computer system are those that aren't there.
    -- Gordon Bell


  8. #8
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: singleton class

    Quote Originally Posted by Graham
    Did no-one else think that they sounded like homework questions?

    A "please" would have been nice...
    The posters of these days...
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  9. #9
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: singleton class

    Quote Originally Posted by Graham
    Did no-one else think that they sounded like homework questions?

    A "please" would have been nice...
    Well...that is why they only got a link (cost me about 10 seconds copy/paste)....otherwise, I might have posted a little bit more...

  10. #10
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: singleton class

    Andreas (and Ejaz) you are a kinder man than I....
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  11. #11
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: singleton class

    Quote Originally Posted by TheCPUWizard
    Andreas (and Ejaz) you are a kinder man than I....
    Well...nah....it is only because it is Tuesday....and Tuesday is my generous day...

  12. #12
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: singleton class

    Especially on THIS Tuesday - Happy Mardi Gras
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  13. #13
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: singleton class

    Quote Originally Posted by TheCPUWizard
    Especially on THIS Tuesday - Happy Mardi Gras
    I know that I post out of topic, but what is this Mardi Gras thing. I heard so many times about Mardi Gras. Is it a day of celebration in New Orleans?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  14. #14
    Join Date
    Feb 2002
    Posts
    4,640

    Re: singleton class

    Quote Originally Posted by cilu
    I know that I post out of topic, but what is this Mardi Gras thing. I heard so many times about Mardi Gras. Is it a day of celebration in New Orleans?
    Not to take this too off topic. Funny you should ask that. According to my calander (it's a "stupid fact a day" type):

    Mardi Gras means "Fat Tuesday", signifying the last day before the Lenten fasting season.

    So, it's a day to stuff yourself, before you have to fast!

    Viggy

  15. #15
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: singleton class

    Mardi Gras is a traditional holiday celebrated in many of the southern states of the USA. The most famous celebration takes place in New Orleans, Louisiana. The people there enjoy this celebration by going to parades where they catch "beads, doubloons, cups, and trinkets" that are all thrown from floats.

    They have masquerade balls and dress up in costumes for these events. King Cakes are eaten during this holiday. Mardi Gras is known as the "biggest free show on earth."

    The History of Mardi Gras...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured