So whenever we want any property of an object (constants, variables, functions, or procedures) to be revealed to others, we just have to set it as a "Public" property (usually done by typing the word "Public" in the beginning of its declaration). And when we don't want it to be, we set it as "Private".
And encapsulation is an advantage because as the programming goes on, we don't have to worry about the same constant, variable, function, or procedure's name within the whole program. Every object has its own properties, and can only be accessed if it was allowed.
No comments:
Post a Comment