As you know, a const-qualified A is not allowed to be directly modified in the following code.
void Main () { const int a = 3; A=1;}
in C + + Const-Modified constants, which cannot be modified directly, but can be indirectly modified by pointers
Take a look at the following example:
The intent is to modify the value of the const constant A through the pointer, but after the run, it is found that the output of a remains the 3,a value surface and has not been changed. But look at the memory window and find that a has been changed, this is the compiler optimization, and when you meet a, the compiler reads 3 to a directly from the register without reading from memory! To improve this situation, we can add a volatile modifier to the definition of a to avoid compiler optimizations:
Const-Modified constants cannot be modified directly but can be indirectly modified by pointers