Point of classes

The following is in "C++ Programming for Game Developers - Module I" from Gameinstitute.com

Third, data can be encapsulated with object-oriented programming. The class writer can enforce which parts of the class are visible to outside code, and which parts should be kept purely internal. In this way the class writer prevents users of the class from accidentally making destructive modifications to internal class data.

When the author talks about "users of the class," is he talking about players of the game using cheats or hacking in order to gain an advantage?
No, he's talking about programmers writing programmes.
Last edited on
No, he is talking about other developers. For example you could write a "Player" class that contains Player state data which has certain restrictions on it like cur_hp cannot be < 0. If you use encapsulation there, you can force it to be >= 0 by checking values that were passed in. If you don't, then obviously someone could simply set the value to -1, which might cause issues somewhere else.
I see. So it prevents a programmer from assigning values to data members within the class that could potentially cause issues within the software.
Topic archived. No new replies allowed.