Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Return reference to instance of singleton

Thread Tools

Return reference to instance of singleton

airportman airportman is offline
Junior Member
Join Date: Feb 2008
Posts: 1

Can somebody tell me why in all the classic implementations of a singleton you have to return a reference to an instance of the class. What is the problem with implementing it as such:

class Singleton



static Singleton s;


Singleton(const Singleton&);
Singleton &operator=(const Singleton&);


The constructor is private and the public instantiation of the object is static. It seems sloppy to allow public access to the object, but is there any other inherent problem?
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Singleton object vs. enhancing singleton class Paul McMahon Ruby 3 06-09-2008 06:05 AM
Singleton Modules rather than Singleton Classes Trans Ruby 12 09-14-2007 06:45 AM
singleton pattern, return sole pt per reference Chris Forone C++ 3 08-16-2007 10:17 AM
Singleton - Whether Cloneable overrides Singleton Proton Projects - Moin Java 4 03-27-2007 02:59 AM
Singleton classes and Singleton pattern Wilhelm Ruby 1 10-11-2006 01:08 PM