3 ms·
> For example, `const` in C++ doesn't mean the data is immutable - it can change with any assignment through a pointer. In C++, an object declared as `const` c
by MauranKilom 7y ago
> For example, `const` in C++ doesn't mean the data is immutable - it can change with any assignment through a pointer.
In C++, an object declared as `const` cannot be changed by assignment through a pointer. Maybe you are thinking of const references?
For example, a `const int x = 10;` cannot be changed. Neither through `const_cast` nor through pointers nor anything else - it's UB in every case.
- WalterBright 7y agopointer to const int