Здесь у меня есть:
class X { public: static int shared_arr[]; static void alloc_and_init() { // Since any static variables defined in the function are allocated some space. // So can I define X::shared_arr here (using the space the static variable for X::shared_arr)? // I think it would be a convenient way to make an approach of some basic memory allocation and initialization. } };
Нет, вам нужно будет определить его точно в одном файле cpp и вне любой функции.
int X::shared_arr[MAX_SIZE] = {0}; ^^^
Обратите внимание, что вам не хватает типа массива.