Bob Doe wrote:
how to I replace singleton classes using function scope static
variables with one that doesn't use function scope static variables?:
What is the problem? What are you trying to replace it with?
Anything in particular? "Not using function scope" is not much
of a specification. Have you looked at possible implementations
of the Singleton pattern? Try googling it. Try looking in some
smart books (like the GoF one). Try looking in the archives.
This has been discussed so many times that it just doesn't need
to be repeated, honestly.
>
class Foo {
public:
static Foo &instance();
virtual ~Foo();
...
private:
Foo();
Foo(const Foo&);
Foo & operator=(const Foo&);
};
----------------------------------
Foo &Foo::instance()
{
static Foo& theInstance;
...
return theInstance;
}
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask