horstman@sjsumcs.sjsu.edu (Cay Horstmann) (03/13/90)
Suppose I wish to hide a numeric constant inside a struct, to avoid cluttering the global name space, and suppose that constant gives the size of another array in the struct. Kind of like struct X { static const int SIZE; int a[ SIZE ]; }; const int X::SIZE = 10; except of course that doesn't work. But struct X { static const int SIZE = 10; int a[ SIZE ]; }; is illegal. I know I could declare X_SIZE outside X, but I LIKE the idea behind static data and functions inside structs/classes. Why clutter up the global name space if you don't have to? Why indeed is the second form declared illegal? It sure beats the yucky syntax of the first case. (Same for initializers of static variables...) Cay