Before getting to the question let me explain my problem.
I´ve made a simple ResourceManager where I could add/get resources (sf::Textures,sf::Font etc) and I made it static inside a "Types" file (yeah , you start seeing the problem
)
When I close the app it will crash (ntdll exception), that confused me a lot.I put down a few breakpoint and the exception was outside of my app.
So I searched google for an answer and I found that I can not use static global things with SFML because we dont know when they will be destroyed and that will cause a few problems.
After this small introduction
, now the question.
How do I make a static/global class?
Can I use a singleton pattern like this:
http://www.yolinux.com/TUTORIALS/C++Singleton.html#include <string>
class Logger{
public:
static Logger* Instance();
bool openLogFile(std::string logFile);
void writeToLogFile();
bool closeLogFile();
private:
Logger(){}; // Private so that it can not be called
Logger(Logger const&){}; // copy constructor is private
Logger& operator=(Logger const&){}; // assignment operator is private
static Logger* m_pInstance;
};
That pattern holds the class as a static pointer, will be this a problem?
Thank you guys!