If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Here it gets initialized on first call, and gets automatically destroyed properly when the program exits. It also eliminates the need for a global.

Err... with an extra static in there... right?

Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.

There are as many ways to write a singleton as fingers on your hand. Don't worry about it too much, as long as you have something working.

Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.

Re: Singleton Method

Are you singling out my implementation specifically? Because the entire pattern is not thread safe, so its not like there's an alternative.

Last edited by monarch_dodra; May 3rd, 2012 at 10:22 AM.

Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.