Singleton implementation
Bo Thorsen
bo at sonofthor.dk
Wed Jul 9 08:46:15 BST 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wednesday 09 July 2003 09:32, Cornelius Schumacher wrote:
> On Wednesday 09 July 2003 07:11, Zack Rusin wrote:
> > I had this on the drive for quite a while - it's a singleton
> > implementation heavily based on the one from "Modern C++ Design".
>
> How do I make a singleton with a private constructor with your class?
> It's often desirable to prevent a singleton from being used without the
> singleton semantics.
friend class KSingleton;
Also, remember to make the destructor private. It's a common failure of
singletons to forget this, and if a piece of code ever does
delete theInstance;
your app dies.
Bo.
- --
Bo Thorsen | Praestevejen 4
Senior Software Engineer | 5290 Marslev
Klarälvdalens Datakonsult | Denmark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
iD8DBQE/C8hNmT99lwfUS5IRAn8yAJ4l3Zikj/3yKVa5Lb5z98GAsJAyZQCgqa2r
P1KwCP8J7lMIy2xlmljtUOA=
=NJ/o
-----END PGP SIGNATURE-----
More information about the kde-core-devel
mailing list