First of all you should never define a static global variable in a header file. Defining a variable static outside of a class has a completely different meaning than defining it static inside of a class. That is very confusing but it's how C++ works.
There are at least four usages of the keyword static in C++:
1) A static global variable outside of a class will only be global to code that can directly "see" the variable normally because they are in the same file. This makes the variable local to the file. As mentioned above you should not put one of these in a header. If you do you will get multiple instances of the same variable. One in each file that includes the header. Changes to one will not affect the others in other files.
2) A static global function has much the same meaning as a static global variable in #1. In general it means the the function will only be called from within the file it is declared in. Like the static global variable if you implement a static global function in a header file you will end up with multiple copies of it in your final executable. However, unlike a static global variable if you put a static global function definition in a header file you will have trouble linking the resulting object files.
3) A static variable in a class means that there will only be one copy of that variable for all instances of the class.
4) A static member function in a class will only be able to access static variables with in that class. All other class data will be inaccessible from a static member function. However, you can call a static member function without a class instance. e.g. A::func()
.
What you probably want is either to use a static class variable or put a extern
definition in a header file like this:
extern int arr[2][2];
Then in an implementation file some where actually create the variable instance, as a non-static variable like this:
int arr[2][2] = {some values};
Make sure you understand the difference between declaration/definition and instantiation/implementation. These are keep concepts in C/C++.