3 ms·
> What's an example of "more fine grained control"? I've used C++ more than Java or C#, but it's not apparent to me how removing a language feature gives you mo
by Chris_Newton 16y ago
> What's an example of "more fine grained control"? I've used C++ more than Java or C#, but it's not apparent to me how removing a language feature gives you more fine grained control.
The point isn't the loss of "const", it's that the only access you do have to a class-type object in C++/Java/C# is via its interface.
If you hold all of an object's current state in private data members, then the only way you can change that state -- even if you can see the object and it isn't const -- is via the interface functions provided. If as class designer you just happen not to provide any interface functions that mutate the object (no set_whatever() calls, no assignment operators, etc.) then your object becomes immutable by implication.
The finer control the GP mentioned probably refers to the way you can also choose to permit certain specific types of mutation, by providing a limited set of functionality in the interface rather than direct access to the underlying values.