0

Why we want to create variables private in a class? It is not easy as public?

Please answer

29th Jan 2019, 5:45 AM
Ajin Ra
Ajin Ra - avatar
2 odpowiedzi
+ 2
Would you like if you card number wasn't private in some class in ATM? That means somebody could very easily hack it and steal your money... Private is used to hide data from user(s) of program
29th Jan 2019, 6:05 AM
Elva
Elva - avatar
+ 3
But then again, data marked private are actually public in memory, the computer doesn't care and you can still easily hack it. :) private has nothing to do with security, it only prevents the programmer from messing things up too badly by disallowing direct access to the variables/functions.
29th Jan 2019, 10:44 AM
Dennis
Dennis - avatar