linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shriramana Sharma <samjnaa@gmail.com>
To: Linux C Programming List <linux-c-programming@vger.kernel.org>
Subject: singleton pattern really necessary?
Date: Sun, 22 Jul 2007 12:02:03 +0530	[thread overview]
Message-ID: <46A2F9E3.9050209@gmail.com> (raw)

I was wondering, if a person wants there to be only one instance of a 
class, they can simply do something like:

class {
<class definition here>
} classInstance ;

which automatically creates a single instance of a class. Why go to the 
extent of locking the constructor, copy constructor, operator= etc? The 
only possible thing (that I can think of) that cannot be done is 
conveniently passing it as an argument to a function. Is there any other 
reason that would make a class-name necessary?

Shriramana Sharma.


                 reply	other threads:[~2007-07-22  6:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46A2F9E3.9050209@gmail.com \
    --to=samjnaa@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).