4 ms·
I'm not that great at C++, but can't you use the const keyword to declare that something's value isn't changing?
by sirseal 12y ago
I'm not that great at C++, but can't you use the const keyword to declare that something's value isn't changing?
- tjradcliffe 12y agoYou can. If you want to write immutable C++ simply declare every single variable const. Done. The only difference between C++ and "immutable by design" languages is that in C++ you'd have to write your own little processor to ensure that your rule is followed (this is no big deal, and I've written much more complex processors to enforce C++ coding standards as part of the build.)
- AgentME 12y agoconst / final in most languages don't prevent the object from being mutated. They just stop the variable binding from being changed.