Bloomberg Interview Question

how does the compiler interpret const keyword and how it can be fooled.

Interview Answer

Anonymous

Nov 4, 2014

It depends (if the variable is initially const, there might be compiler optimizations which cannot be fooled, i.e. the compiler is allowed to use the value directly in that case). But the general answer to this is const_cast. And I would add, very bad and dangerous practice (the data might be stored in read-only memory segment as well).