Exercise: Access Methods for Members¶
In exercise Exercise: Simple Method (Users Age By n Years), you had to modify
class User: you removed the
const specifier from the
age is still
public, which gives everybody permission
to write to
age - not only class methods.
private section, and put all (not just
that section. This will break all code that accesses members
Fix that: introduce access methods for the members.