Re: Threadsafe singletons
Matthias Hofmann wrote:
"David Barrett-Lennard" <davidbl@iinet.net.au> schrieb im Newsbeitrag
news:1154351660.579817.182420@m73g2000cwd.googlegroups.com...
BTW I also suggest you use a proper string member rather
than simply alias a null terminated string with a char
pointer. It's rather dangerous.
What could happen? The only thing I can imagine is using the
char pointer to modify the string literal. This can be fixed
by using a pointer to a const char.
void
muckItUp()
{
char doh[] = "How long will I exist?" ;
Singleton::GetInstance().SetName( doh ) ;
}
I wouldn't like to use the singleton after a call to muckItUp.
--
James Kanze GABI Software
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]