I've been wondering. I've seen a lot of classes that have private variables, and then have public functions for accessing them. My question is... why?
Surley it would be faster to set the variables directly. It would also be easier to code, as well as lowering the space needed by the class. The only reason I can think of for using accessor functions is so that I can check some values arent out of bounds, like setting a width of a window to a number less than 0. But if the whole program is being written by myself and people on my team, then what does it matter? Surley I can make EVERYTHING in the class public, since I'm the only one that will change it anyway. So why would I want to use accessor functions for variables in my own classes?