Quote Originally Posted by 2kaud View Post
The big question I have about all of this is - why??

Your class test has the class variables public so that any user of this class can set/get the contents of these variables at will (ok with a nod towards the restrictions) but basically these are public class variables.

The whole point of having private class variables and public getter/setter functions is to separate the underlying representation of the data with the public use of that data. So if, at a later date, it is required to change the underlying private data representation, this can be done without making changes to the public interface. Indeed, users of the class need never know that the underlying data representation has changed.

In this case, if the test class data representation is changed, then all the code that uses that data has to be changed as well! Take a simple example. In class test you are storing the age as an integer. What about later if you want to store the age as say the number of days since 1900? As age is public, all uses of age have to be found and changed. Using class get/set functions GetAge(..) and SetAge(..) just these two functions would need to be changed to accomodate the data representation change.
sorry to both, but it's a person thing. i love use properties instead Get\Set. sorry