0 votes
625 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 563 views
asked May 25, 2021 in General by Tester jjavelin (120 points)
0 votes
1 answer 1.4k views
0 votes
1 answer 629 views
asked Oct 29, 2021 in General by anonymous
0 votes
1 answer 12.5k views
asked Aug 19, 2016 in General by Shed
0 votes
1 answer 645 views
asked Oct 29, 2021 in General by anonymous
...