0
Why do we need private variables?
2 odpowiedzi
+ 2
There are some variables that are not meant to be used by other classes. Accessing and modifying them could mess up the program in some cases, but mostly it is against the principle of information hiding and encapsulation. Should every cell broadcast exactly what its lysosomes are doing to every other cell? No, other cells only need to know what type of cell it is and whether it’s infected. Or, do you want to know the state of every single atom in a chair? No, you just need to know if it’s broken or dirty.
0
Thanks 👍🏻