4 ms·
Hiding members in this way is only possible with pointer indirection, which isn't satisfying. However, having only a boolean private/public access state isn't
by jstimpfle 3y ago
Hiding members in this way is only possible with pointer indirection, which isn't satisfying.
However, having only a boolean private/public access state isn't generally satisfying either. It often leads to violation of the principle of separation of concerns when all the functions (methods) acting on certain "private" fields need to live in the same class.
In simple classes, like std::vector, it's possible to get away with private. But in many cases that are more complex than that, it seems to me that the best approach is still to expose the data and to be just very clear about the exact purpose of each member.