Course Object Oriented Programming
Visibility
Hello, in this class we will learn about visibility and classes.
Visibility
Defining visibility means defining which scopes can access certain members.
By using the visibility settings, we can ensure that members are only accessed from certain scopes. Ensuring that you can only use valid actions with class objects.
Using the analogy from the previous lesson, the controller buttons are visible, the internal circuit is hidden.
Type of visibility
- Public: Members can be accessed from any scope.
- Private: Members can only be accessed from the scope of the class itself.
- Protected: Members are only accessible from the scope of the class itself and from the scope of child classes (classes they inherit).
Obs: We will study the protected visibility when we go to study inheritance, because these two subjects are linked.