0 votes
838 views
in General by
When and why should I use public, private, and protected functions and variables inside a class? What is the difference between them?

1 Answer

0 votes
by
  • Public scope to make that property/method available from anywhere, other classes and instances of the object.
  • Private scope when you want your property/method to be visible in its own class only.
  • Protected scope when you want to make your property/method visible in all classes that extend current class including the parent class.

Related questions

0 votes
1 answer 775 views
asked May 25, 2021 in General by Tester jjavelin (120 points)
0 votes
1 answer 1.7k views
0 votes
1 answer 972 views
asked Oct 29, 2021 in General by anonymous
0 votes
1 answer 12.8k views
asked Aug 19, 2016 in General by Shed
0 votes
1 answer 1.0k views
asked Oct 29, 2021 in General by anonymous
...