array declaration and definition

Hello!
I have the following problem.
I declare in someClass.hpp file some class with static members:
1
2
3
4
5
6
7
class A
{
...
public:
    static int arr[];
...
};

Then, in someclass.cpp define static members:
 
int A::arr[] = {1,2,3,4};

When I try to get the size of it in someOtherFile.cpp:
1
2
3
4
5
void somefunc()
{
    size_t s = sizeof(A::arr);
    ...
}

I get error message "incomplete type is not allowed".
So, the question is: what am i doing wrong? How can i acquire the size of array in other .cpp file?
You have to state the size of the array in the class declaration, otherwise the compiler can't know how big A is.
So i have to declare the size of array explicitly, and there is no other way to workaround it?
You could change the array into a pointer and allocate it dynamically. Otherwise, no.
Topic archived. No new replies allowed.