C++ Accidental Access to Private Object Variable
Posted on 2013-01-11
Given a class with a private variable and a public getter method, if a programmer were to return a reference to the private variable, then users of that method could have direct modifiable access to that private variable (i.e., modify the variable value without using an object method).
I don't like this. (Tough luck on me, I guess. But why would the C++ standard allow this?)
Is there a way to keep private variables truly private so that the above cannot happen?