From ISO/IEC 14882:2003 8.3.4/1:
If the constant-expression (5.19) is present, it shall be an integral constant expression and its value shall be greater than zero.
Therefore the following should not compile:
#pragma once
class IAmAClass
{
public:
    IAmAClass();
    ~IAmAClass();
private:
    int somearray[0];    // Zero sized array
};
But it does. However, the following:
#pragma once
class IAmAClass
{
public:
    IAmAClass();
    ~IAmAClass();
private:
    int somearray[0];
    int var = 23;     // Added this expression
};
does not compile, with the following error (as what would be expected) (Visual C++)
error C2229: class 'IAmAClass' has an illegal zero-sized array
When the code is in a function, it, in accordance with the standard, will never compile.
So, why does the code behave in such a way in a header file, where the difference of the compilation passing or failing appears to be down to whether a statement proceeds the zero sized array declaration or not.
 
    