const int arrSize=10;
cout <& lt;" ArrSize="& lt;
Int * parrSize=const_cast & lt; Int * & gt; (& amp; ArrSize);
(* parrSize) + +;
cout <"ArrSize=" & lt;
Program output:
10 Addr arrSize==00 c3f808
10 Addr arrSize==00 c3f808
* 11 Addr parrSize==00 c3f808
Clearly address is the same, why itself value is different? Has been under the Debug and Release test is,
There are two question consult everybody, check a lot of information, some said const definition of built-in type, do not need to allocate memory (it wasn't quite right. After all, can address?) , some say as long as a allocated memory, no longer in the subsequent use allocation (individual feels more solid), and, in the compile phase defined in the symbol table, this variable is not included in the real exe (not understand), is there any authority point, exactly what kind of situation? Second, the compiler is not a modification of how to realize the const? Just to check whether the assignment operation is in the code to judge illegal? Or like macros defined as constants to replace directly? Thank you very much!