Using const
prevents a variable from being changed. Easy enough.
const int x = 5;
x = 6; //not allowed!
But how is this actually being implemented?
Is it just a compiler rule? Or is there something happening at the machine code level that distinguishes between const and non-const variables?
edit: my question is distinct from this since that question was only asking about how the compiler keeps track of what is const
and what isn't. My question is not this. My question is about the actual machine-code-level meaning of const, if there is one (seems like it might just be a compiler hint). At any rate, just take a look at how the answers to my question and the answers to the linked question are different. That should give you a hint that this isn't a duplicate.
edit: The 'duplicate' question about accessing members in a derived class is not duplicate. Different question, different answer.