0

hi, All.
I know that how to use public, protected and private variables.
for ex: public i can use it another class, protected i can use in main and being inherited class and private only the class where it declared.
but i dont understand what is purpose to it public, private, or protected. what does it mean?

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by MooGeek
0

It's for example to show other coders that are working on the same project as you how they should use your class.

0

Public == Available to everyone who can access the class
Private == Available only within the class where the function/variable is
declared
protected = Available only within the class, or any class that is derived
from the class

Let me know if you need more :)

0

Thank you very much. I understood the visibility (public, protected, private) of these fields. but i didnt understand for what reason and where are used these visibility methods?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.