Heres some modified code for a singleton that I got out of a book. This is sort of what I was thinking of doing, but thought it would be cheesy, but this looks good. It creates an instance of Window and returns a pointer to that instance, unless one has already been created in which case it returns that instance. Hence only one instance of the class exists in the program. Both extern and this would get the job done, just passing this by. (since I do find it more elegant).
Code:
#window.h
class Window {
public:
static Window* Instance();
protected:
Window() {}
private:
static Window* m_instance;
};
Window* Window::m_instance = 0;
Window* Window::Instance () {
if(m_instance == 0) {
m_instance = new Window;
}
return m_instance;
}
It doesn't say, but I would think calling: Window* gwindow = Window::Instance(); in the files you need gwindow would work, or call it directly and skipping the gwindow part.