From: William E. Kempf (williamkempf_at_[hidden])
Date: 2002-08-07 08:56:26


From: "Rene Rivera" <grafik666_at_[hidden]>
> Hmmm, maybe I missed something but... If it's singleton type data why not
> make it static? Or is making it static the problem? If it is I tend to use
> this solution for static class lazy init data...
>
> class something
> {
> public:
> something();
> void print() { cout << data(); }
> int get() { return data(); }
> void set(int aValue) { data() = aValue; }
>
> protected:
> int & data()
> {
> static int sData = 10;
> return sData;
> }
> };
>
> Is this what you really want?

No, because that's not thread safe (or at least it's not gauranteed to be,
and varies from compiler to compiler).

Bill Kempf