futurized
trying to learn encapsulation
Encapsulation is used to hide the values or state of a structured data object inside a class, preventing unauthorized parties’ direct access to them. Publicly accessible methods are generally provided in the class (so-called getters and setters) to access the values, and other client classes call these methods to retrieve and modify the values within the object.I'm not really understanding this as why can't an unauthorised party just, for example, write obj1.GetAge()? How would encapsulation prevent access?
43 replies