Oop Discussion | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Oop Discussion

Ok so this is not a question but a discussion. And the question that arises is why use Private and Public Classes(used in many languages)

10th Sep 2020, 10:44 AM
Kunsh-Tyagi
Kunsh-Tyagi - avatar
2 Answers
+ 2
public classes are the default in most languages I know. It basically means that any non private(and non protected) attribute or method is accessible by any other class. A private class is not visible to any class. It is therefore useless except if it is an inner class. Classes can usually "see" their inner classes whether it is private or not. I am yet to know a good use case for private/protected classes yet.
10th Sep 2020, 11:45 AM
Ore
Ore - avatar
+ 2
@ore same here do tell here if you find out ;)
11th Sep 2020, 11:22 AM
Kunsh-Tyagi
Kunsh-Tyagi - avatar