Re: Composition - accessing & updating members
Quote:
Originally Posted by
Chris_F
You don't need encapsulation to provide a robust interface for a coordinate class. Like I said, It's not an invariant, and the glm::vec3 class I mentioned is a perfect example. Encapsulating it is just plain silly.
You need encapsulation if you want to prevent someone from writing the kind of code in my last post (#4).
Of course, real-world C++ libraries are designed for experienced C++ programmers and are not going to prevent users from shooting themselves in the foot if that means denying certain possibilities. So the fact that in all the libraries you mentioned a vector is a POD type, does not mean that a vector should always be a POD type. It's a design choice, and I doubt the design goals of the OP are the same as the design goals for those libraries.