C++ Const and Enum Bob Walton, 7/16/96 Data declared at top level (outside any function or class declaration) may be declared to be const. Such data is implicitly declared to be static so that it will be local to its translation unit: i.e. the .cc file currently being compiled. Thus int const i = 5; is equivalent to: static int const i = 5; Integer constants declared in this way and given values that can be computed at compile time may be used in expressions that declare the sizes of arrays, and in other places where a compile time integer is required. Because the `= 5' type of initializer is not permitted for a class data member, const data members of classes cannot be assigned values in this way, and cannot be used as array dimensions. Instead, enum constants must be used, as in: class foo { enum { TABLE_SIZE = 101 }; int table [ TABLE_SIZE ]; }; ... foo::TABLE_SIZE ... Future versions of C++ may allow const int data members to have initializers such as `= 5'.