what are public and private functions?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what are public and private functions??

15th Aug 2016, 8:11 AM
Muhammad Arslan Shahid
Muhammad Arslan Shahid - avatar
2 Answers
+ 3
Public and private are access specifiers for a class. Public members can be accessed anywhere in the program through the use of an object. Private members can only be accessed from other members inside the class. To answer your question, the term "members" applies to functions too.
15th Aug 2016, 10:05 AM
Cohen Creber
Cohen Creber - avatar
+ 1
Extending on Cohen's answer, classes can be made 'friends' of one another. Classes that are friendly with one another can access the private members of one another's classes as well as the public members.
15th Aug 2016, 3:15 PM
Ahkrin