static arrays defined with unspecified size, empty brackets?
- by ahmadabdolkader
For the C++ code fragment below:
class Foo {
int a[]; // no error
};
int a[]; // error: storage size of 'a' isn't known
void bar() {
int a[]; // error: storage size of 'a' isn't known
}
why isn't the member variable causing an error too? and what is the meaning of this member variable?
I'm using gcc version 3.4.5 (mingw-vista special) through CodeBlocks 8.02.
On Visual Studio Express 2008 - Microsoft(R) C/C++ Optimizing Compiler 15.00.30729.01 for 80x86, I got the following messages:
class Foo {
int a[]; // warning C4200: nonstandard extension used : zero-sized array in struct/union - Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array
};
int a[];
void bar() {
int a[]; // error C2133: 'a' : unknown size
}
Now, this needs some explaination too.