variables within a class private | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

variables within a class private

why its not the rule?

19th Dec 2019, 1:25 PM
Lenyuk Michal
1 Answer
+ 1
It is the rule. You must have heard about encapsulation, so exposing every variable of the class is not recommended because you do not want every user to alter the value of a program that you created. Edit: Need not be private at all times but it is a good practice.
19th Dec 2019, 1:37 PM
Avinesh
Avinesh - avatar