TITLE: const and storage efficiency PROBLEM: jskim@rose.etri.re.kr (Kim Jungsun) In C++, I prefer const to #define as suggested by many gurus. And I know that "enum" can be used to simulate class specific constants. My question is then is there any criteria on choosing between "const" and "enum" when we want to define constant(s) in gloabl scope? RESPONSE: "Guenter Nagler" As you already guessed there are some advantages of enum constants: ... [ good observations deleted ] e) enum constants cannot be changed at runtime (no storage needed for the constants itself (only enum variables need storage)). RESPONSE: clamage@Eng.Sun.COM (Steve Clamage), 8 Jul 95 Const variables of simple type do not necessarily require storage. That is, the code that is generated using enum { size = 1000 }; will probably remain identical if you change the definition to const int size = 1000; On the other hand, const integers are lvalues, so you can take the address. An enum is not an lvalue, so you can't. Example: const int iSize = 100; enum eee { eSize } = 100; int aray1[iSize]; // ok int aray2[eSize]; // ok const int* ip1 = &iSize; // ok, compiler allocates storage for ip1 const eee* ip2 = &eSize; // error, eSize does not have a location RESPONSE: "Guenter Nagler" In C/C++ it is allowed to change const values at runtime indirect by using pointers to them. RESPONSE: clamage@Eng.Sun.COM (Steve Clamage) Not so. You can attempt to change a const variable by using casts, but the results of doing so are undefined. There is no guarantee that the program will work. In particular, the compiler is allowed to put the variable in read-only memory.