variables within a class private | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

variables within a class private

why its not the rule?

19th Dec 2019, 1:25 PM
Lenyuk Michal
1 Réponse
+ 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