I had a question regarding the usage of the static keyword in C++. Basically, what I am attempting to achieve is this- I am constructing a mouse class that will handle mouse input, and I was trying to make the class itself hold a static member that is of the mouse class itself, so that there would be no need for a global mouse object. For example:
private:
static CMouse m_mouse;
public:
// Accessor method
static CMouse GetMouse() { return m_mouse; }
My problem is that it gives me an error when I try to call a function, in the main() of the program like so:
int main()
{
CMouse::GetMouse().Init();
}
The error says that the symbol "m_mouse" cannot be found. I think I understand why this happens, but can anyone tell me how to fix it (because I would prefer this to a global mouse object)?