TITLE: Handling array dimensions with statics PROBLEM: hopps@yellow.mmm.com (Kevin J Hopps) It appears as though a const int takes up memory just like a normal int, except that it is read-only. RESPONSE: jimad@microsoft.com (Jim Adcock), 14 Apr 93 [a] Try using a static const int member. Good compilers shouldn't use any memory for this, unless you take its address. [b] The static const int member indeed cannot be given defined value inside the class declaration, meaning it cannot be used for array sizing. For array sizing you'd be forced to use a class enum. [c] Most of what you want can be done, it just requires a lot of differing and crappy hacks. I believe there are proposals before the committee for allowing constants to be defined within the class declaration, which would seem to solve these current shortcomings. RESPONSE: jamshid@emx.cc.utexas.edu (Jamshid Afshar) [a] Are you sure? I could see how a smart linker could handle the situations discussed here, but there's no way in general for the compiler to know whether the static data member will be initialized with a run-time expression. [b] Right. I think the only situation where a compile-time constant is required, besides an array size specification or preprocessor expression, is when specififying a constant (non-type) template argument. template class Range {/*...*/}; typedef Range Degree; //(actually, current compilers don't handle the above immediate // use of 'T', but I think ANSI is considering it) [c] I suggest using an inline static member function (unless of course ANSI comes up with something better). The constant will definitely be inlined and you don't have to bother with a separate definition. And an extra set of parenthesis never killed anyone. :-) class Foo { public: static long MAXCOUNT() { return 5000000; } static unsigned MASK() { return 0xF0F0; } }; ... if ( (x & Foo::MASK())!=0 && n