While going over my friend's code, I noticed he had
Having no idea what empty array brackets at the end of declaration like that do (it looks like it should statically allocate like counts[10] or counts[20], but the lack of number implies dynamic allocation), or even why it compiled, I messed around.Code:class A { public: ... private: int counts[]; };
Yet, if I attempt
I get a compile error, because a size is not specified. On the other hand, putting this is a member of a class appears to yield an array of size zero.Code:int main() { int counts[]; }
What exactly is the point of this syntax, why allow the creation of arrays of size zero in a class, but not nomrally, etc. etc.?



LinkBack URL
About LinkBacks


